@@ -154,7 +154,7 @@ |
||
| 154 | 154 | /** |
| 155 | 155 | * @param string $handle |
| 156 | 156 | * @param bool $echo |
| 157 | - * @return bool |
|
| 157 | + * @return string|boolean |
|
| 158 | 158 | */ |
| 159 | 159 | public function print_inline_style( $handle, $echo = true ) { |
| 160 | 160 | $output = $this->get_data( $handle, 'after' ); |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * BackPress Styles enqueue. |
|
| 4 | - * |
|
| 5 | - * These classes were refactored from the WordPress WP_Scripts and WordPress |
|
| 6 | - * script enqueue API. |
|
| 7 | - * |
|
| 8 | - * @package BackPress |
|
| 9 | - * @since r74 |
|
| 10 | - */ |
|
| 3 | + * BackPress Styles enqueue. |
|
| 4 | + * |
|
| 5 | + * These classes were refactored from the WordPress WP_Scripts and WordPress |
|
| 6 | + * script enqueue API. |
|
| 7 | + * |
|
| 8 | + * @package BackPress |
|
| 9 | + * @since r74 |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * BackPress Styles enqueue class. |
@@ -36,49 +36,49 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param WP_Styles &$this WP_Styles instance, passed by reference. |
| 38 | 38 | */ |
| 39 | - do_action_ref_array( 'wp_default_styles', array(&$this) ); |
|
| 39 | + do_action_ref_array('wp_default_styles', array(&$this)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param string $handle |
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | - public function do_item( $handle ) { |
|
| 47 | - if ( !parent::do_item($handle) ) |
|
| 46 | + public function do_item($handle) { |
|
| 47 | + if ( ! parent::do_item($handle)) |
|
| 48 | 48 | return false; |
| 49 | 49 | |
| 50 | 50 | $obj = $this->registered[$handle]; |
| 51 | - if ( null === $obj->ver ) |
|
| 51 | + if (null === $obj->ver) |
|
| 52 | 52 | $ver = ''; |
| 53 | 53 | else |
| 54 | 54 | $ver = $obj->ver ? $obj->ver : $this->default_version; |
| 55 | 55 | |
| 56 | - if ( isset($this->args[$handle]) ) |
|
| 57 | - $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
| 56 | + if (isset($this->args[$handle])) |
|
| 57 | + $ver = $ver ? $ver.'&'.$this->args[$handle] : $this->args[$handle]; |
|
| 58 | 58 | |
| 59 | - if ( $this->do_concat ) { |
|
| 60 | - if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) { |
|
| 59 | + if ($this->do_concat) { |
|
| 60 | + if ($this->in_default_dir($obj->src) && ! isset($obj->extra['conditional']) && ! isset($obj->extra['alt'])) { |
|
| 61 | 61 | $this->concat .= "$handle,"; |
| 62 | 62 | $this->concat_version .= "$handle$ver"; |
| 63 | 63 | |
| 64 | - $this->print_code .= $this->print_inline_style( $handle, false ); |
|
| 64 | + $this->print_code .= $this->print_inline_style($handle, false); |
|
| 65 | 65 | |
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if ( isset($obj->args) ) |
|
| 71 | - $media = esc_attr( $obj->args ); |
|
| 70 | + if (isset($obj->args)) |
|
| 71 | + $media = esc_attr($obj->args); |
|
| 72 | 72 | else |
| 73 | 73 | $media = 'all'; |
| 74 | 74 | |
| 75 | - $href = $this->_css_href( $obj->src, $ver, $handle ); |
|
| 76 | - if ( empty( $href ) ) { |
|
| 75 | + $href = $this->_css_href($obj->src, $ver, $handle); |
|
| 76 | + if (empty($href)) { |
|
| 77 | 77 | // Turns out there is nothing to print. |
| 78 | 78 | return true; |
| 79 | 79 | } |
| 80 | 80 | $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; |
| 81 | - $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; |
|
| 81 | + $title = isset($obj->extra['title']) ? "title='".esc_attr($obj->extra['title'])."'" : ''; |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Filter the HTML link tag of an enqueued style. |
@@ -90,19 +90,19 @@ discard block |
||
| 90 | 90 | * @param string $handle The style's registered handle. |
| 91 | 91 | * @param string $href The stylesheet's source URL. |
| 92 | 92 | */ |
| 93 | - $tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href ); |
|
| 94 | - if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) { |
|
| 95 | - if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) { |
|
| 96 | - $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : ''; |
|
| 97 | - $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" )); |
|
| 93 | + $tag = apply_filters('style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href); |
|
| 94 | + if ('rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl']) { |
|
| 95 | + if (is_bool($obj->extra['rtl']) || 'replace' === $obj->extra['rtl']) { |
|
| 96 | + $suffix = isset($obj->extra['suffix']) ? $obj->extra['suffix'] : ''; |
|
| 97 | + $rtl_href = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href($obj->src, $ver, "$handle-rtl")); |
|
| 98 | 98 | } else { |
| 99 | - $rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" ); |
|
| 99 | + $rtl_href = $this->_css_href($obj->extra['rtl'], $ver, "$handle-rtl"); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** This filter is documented in wp-includes/class.wp-styles.php */ |
| 103 | - $rtl_tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle, $rtl_href ); |
|
| 103 | + $rtl_tag = apply_filters('style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle, $rtl_href); |
|
| 104 | 104 | |
| 105 | - if ( $obj->extra['rtl'] === 'replace' ) { |
|
| 105 | + if ($obj->extra['rtl'] === 'replace') { |
|
| 106 | 106 | $tag = $rtl_tag; |
| 107 | 107 | } else { |
| 108 | 108 | $tag .= $rtl_tag; |
@@ -110,22 +110,22 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $conditional_pre = $conditional_post = ''; |
| 113 | - if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) { |
|
| 113 | + if (isset($obj->extra['conditional']) && $obj->extra['conditional']) { |
|
| 114 | 114 | $conditional_pre = "<!--[if {$obj->extra['conditional']}]>\n"; |
| 115 | 115 | $conditional_post = "<![endif]-->\n"; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( $this->do_concat ) { |
|
| 118 | + if ($this->do_concat) { |
|
| 119 | 119 | $this->print_html .= $conditional_pre; |
| 120 | 120 | $this->print_html .= $tag; |
| 121 | - if ( $inline_style = $this->print_inline_style( $handle, false ) ) { |
|
| 122 | - $this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); |
|
| 121 | + if ($inline_style = $this->print_inline_style($handle, false)) { |
|
| 122 | + $this->print_html .= sprintf("<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr($handle), $inline_style); |
|
| 123 | 123 | } |
| 124 | 124 | $this->print_html .= $conditional_post; |
| 125 | 125 | } else { |
| 126 | 126 | echo $conditional_pre; |
| 127 | 127 | echo $tag; |
| 128 | - $this->print_inline_style( $handle ); |
|
| 128 | + $this->print_inline_style($handle); |
|
| 129 | 129 | echo $conditional_post; |
| 130 | 130 | } |
| 131 | 131 | |
@@ -136,19 +136,19 @@ discard block |
||
| 136 | 136 | * @param string $handle |
| 137 | 137 | * @param string $code |
| 138 | 138 | */ |
| 139 | - public function add_inline_style( $handle, $code ) { |
|
| 140 | - if ( ! $code ) { |
|
| 139 | + public function add_inline_style($handle, $code) { |
|
| 140 | + if ( ! $code) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $after = $this->get_data( $handle, 'after' ); |
|
| 145 | - if ( ! $after ) { |
|
| 144 | + $after = $this->get_data($handle, 'after'); |
|
| 145 | + if ( ! $after) { |
|
| 146 | 146 | $after = array(); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $after[] = $code; |
| 150 | 150 | |
| 151 | - return $this->add_data( $handle, 'after', $after ); |
|
| 151 | + return $this->add_data($handle, 'after', $after); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | * @param bool $echo |
| 157 | 157 | * @return bool |
| 158 | 158 | */ |
| 159 | - public function print_inline_style( $handle, $echo = true ) { |
|
| 160 | - $output = $this->get_data( $handle, 'after' ); |
|
| 159 | + public function print_inline_style($handle, $echo = true) { |
|
| 160 | + $output = $this->get_data($handle, 'after'); |
|
| 161 | 161 | |
| 162 | - if ( empty( $output ) ) { |
|
| 162 | + if (empty($output)) { |
|
| 163 | 163 | return false; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $output = implode( "\n", $output ); |
|
| 166 | + $output = implode("\n", $output); |
|
| 167 | 167 | |
| 168 | - if ( ! $echo ) { |
|
| 168 | + if ( ! $echo) { |
|
| 169 | 169 | return $output; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - printf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $output ); |
|
| 172 | + printf("<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr($handle), $output); |
|
| 173 | 173 | |
| 174 | 174 | return true; |
| 175 | 175 | } |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | * @param mixed $group |
| 181 | 181 | * @return bool |
| 182 | 182 | */ |
| 183 | - public function all_deps( $handles, $recursion = false, $group = false ) { |
|
| 184 | - $r = parent::all_deps( $handles, $recursion ); |
|
| 185 | - if ( !$recursion ) { |
|
| 183 | + public function all_deps($handles, $recursion = false, $group = false) { |
|
| 184 | + $r = parent::all_deps($handles, $recursion); |
|
| 185 | + if ( ! $recursion) { |
|
| 186 | 186 | /** |
| 187 | 187 | * Filter the array of enqueued styles before processing for output. |
| 188 | 188 | * |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @param array $to_do The list of enqueued styles about to be processed. |
| 192 | 192 | */ |
| 193 | - $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); |
|
| 193 | + $this->to_do = apply_filters('print_styles_array', $this->to_do); |
|
| 194 | 194 | } |
| 195 | 195 | return $r; |
| 196 | 196 | } |
@@ -201,12 +201,12 @@ discard block |
||
| 201 | 201 | * @param string $handle |
| 202 | 202 | * @return string |
| 203 | 203 | */ |
| 204 | - public function _css_href( $src, $ver, $handle ) { |
|
| 205 | - if ( !is_bool($src) && !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { |
|
| 206 | - $src = $this->base_url . $src; |
|
| 204 | + public function _css_href($src, $ver, $handle) { |
|
| 205 | + if ( ! is_bool($src) && ! preg_match('|^(https?:)?//|', $src) && ! ($this->content_url && 0 === strpos($src, $this->content_url))) { |
|
| 206 | + $src = $this->base_url.$src; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( !empty($ver) ) |
|
| 209 | + if ( ! empty($ver)) |
|
| 210 | 210 | $src = add_query_arg('ver', $ver, $src); |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | * @param string $src The source URL of the enqueued style. |
| 218 | 218 | * @param string $handle The style's registered handle. |
| 219 | 219 | */ |
| 220 | - $src = apply_filters( 'style_loader_src', $src, $handle ); |
|
| 221 | - return esc_url( $src ); |
|
| 220 | + $src = apply_filters('style_loader_src', $src, $handle); |
|
| 221 | + return esc_url($src); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | * @return bool |
| 227 | 227 | */ |
| 228 | 228 | public function in_default_dir($src) { |
| 229 | - if ( ! $this->default_dirs ) |
|
| 229 | + if ( ! $this->default_dirs) |
|
| 230 | 230 | return true; |
| 231 | 231 | |
| 232 | - foreach ( (array) $this->default_dirs as $test ) { |
|
| 233 | - if ( 0 === strpos($src, $test) ) |
|
| 232 | + foreach ((array) $this->default_dirs as $test) { |
|
| 233 | + if (0 === strpos($src, $test)) |
|
| 234 | 234 | return true; |
| 235 | 235 | } |
| 236 | 236 | return false; |
@@ -44,17 +44,20 @@ discard block |
||
| 44 | 44 | * @return bool |
| 45 | 45 | */ |
| 46 | 46 | public function do_item( $handle ) { |
| 47 | - if ( !parent::do_item($handle) ) |
|
| 48 | - return false; |
|
| 47 | + if ( !parent::do_item($handle) ) { |
|
| 48 | + return false; |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | 51 | $obj = $this->registered[$handle]; |
| 51 | - if ( null === $obj->ver ) |
|
| 52 | - $ver = ''; |
|
| 53 | - else |
|
| 54 | - $ver = $obj->ver ? $obj->ver : $this->default_version; |
|
| 52 | + if ( null === $obj->ver ) { |
|
| 53 | + $ver = ''; |
|
| 54 | + } else { |
|
| 55 | + $ver = $obj->ver ? $obj->ver : $this->default_version; |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | - if ( isset($this->args[$handle]) ) |
|
| 57 | - $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
| 58 | + if ( isset($this->args[$handle]) ) { |
|
| 59 | + $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | if ( $this->do_concat ) { |
| 60 | 63 | if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) { |
@@ -67,10 +70,11 @@ discard block |
||
| 67 | 70 | } |
| 68 | 71 | } |
| 69 | 72 | |
| 70 | - if ( isset($obj->args) ) |
|
| 71 | - $media = esc_attr( $obj->args ); |
|
| 72 | - else |
|
| 73 | - $media = 'all'; |
|
| 73 | + if ( isset($obj->args) ) { |
|
| 74 | + $media = esc_attr( $obj->args ); |
|
| 75 | + } else { |
|
| 76 | + $media = 'all'; |
|
| 77 | + } |
|
| 74 | 78 | |
| 75 | 79 | $href = $this->_css_href( $obj->src, $ver, $handle ); |
| 76 | 80 | if ( empty( $href ) ) { |
@@ -206,8 +210,9 @@ discard block |
||
| 206 | 210 | $src = $this->base_url . $src; |
| 207 | 211 | } |
| 208 | 212 | |
| 209 | - if ( !empty($ver) ) |
|
| 210 | - $src = add_query_arg('ver', $ver, $src); |
|
| 213 | + if ( !empty($ver) ) { |
|
| 214 | + $src = add_query_arg('ver', $ver, $src); |
|
| 215 | + } |
|
| 211 | 216 | |
| 212 | 217 | /** |
| 213 | 218 | * Filter an enqueued style's fully-qualified URL. |
@@ -226,12 +231,14 @@ discard block |
||
| 226 | 231 | * @return bool |
| 227 | 232 | */ |
| 228 | 233 | public function in_default_dir($src) { |
| 229 | - if ( ! $this->default_dirs ) |
|
| 230 | - return true; |
|
| 234 | + if ( ! $this->default_dirs ) { |
|
| 235 | + return true; |
|
| 236 | + } |
|
| 231 | 237 | |
| 232 | 238 | foreach ( (array) $this->default_dirs as $test ) { |
| 233 | - if ( 0 === strpos($src, $test) ) |
|
| 234 | - return true; |
|
| 239 | + if ( 0 === strpos($src, $test) ) { |
|
| 240 | + return true; |
|
| 241 | + } |
|
| 235 | 242 | } |
| 236 | 243 | return false; |
| 237 | 244 | } |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | * |
| 694 | 694 | * @since 1.5.0 |
| 695 | 695 | * |
| 696 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 696 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 697 | 697 | * @return string The link to the comments. |
| 698 | 698 | */ |
| 699 | 699 | function get_comments_link( $post_id = 0 ) { |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @since 1.5.0 |
| 732 | 732 | * |
| 733 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 733 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 734 | 734 | * @return int The number of comments a post has. |
| 735 | 735 | */ |
| 736 | 736 | function get_comments_number( $post_id = 0 ) { |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Comment template functions |
|
| 4 | - * |
|
| 5 | - * These functions are meant to live inside of the WordPress loop. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - * @subpackage Template |
|
| 9 | - */ |
|
| 3 | + * Comment template functions |
|
| 4 | + * |
|
| 5 | + * These functions are meant to live inside of the WordPress loop. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + * @subpackage Template |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Retrieve the author of the current comment. |
@@ -2231,11 +2231,11 @@ discard block |
||
| 2231 | 2231 | $html5 = 'html5' === $args['format']; |
| 2232 | 2232 | $fields = array( |
| 2233 | 2233 | 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
| 2234 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>', |
|
| 2234 | + '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>', |
|
| 2235 | 2235 | 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
| 2236 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2236 | + '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2237 | 2237 | 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
| 2238 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
|
| 2238 | + '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
|
| 2239 | 2239 | ); |
| 2240 | 2240 | |
| 2241 | 2241 | $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
@@ -19,11 +19,11 @@ discard block |
||
| 19 | 19 | * @param int $comment_ID Optional. The ID of the comment for which to retrieve the author. Default current comment. |
| 20 | 20 | * @return string The comment author |
| 21 | 21 | */ |
| 22 | -function get_comment_author( $comment_ID = 0 ) { |
|
| 23 | - $comment = get_comment( $comment_ID ); |
|
| 22 | +function get_comment_author($comment_ID = 0) { |
|
| 23 | + $comment = get_comment($comment_ID); |
|
| 24 | 24 | |
| 25 | - if ( empty( $comment->comment_author ) ) { |
|
| 26 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
| 25 | + if (empty($comment->comment_author)) { |
|
| 26 | + if ($comment->user_id && $user = get_userdata($comment->user_id)) |
|
| 27 | 27 | $author = $user->display_name; |
| 28 | 28 | else |
| 29 | 29 | $author = __('Anonymous'); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param int $comment_ID The comment ID. |
| 42 | 42 | * @param object $comment The comment object. |
| 43 | 43 | */ |
| 44 | - return apply_filters( 'get_comment_author', $author, $comment_ID, $comment ); |
|
| 44 | + return apply_filters('get_comment_author', $author, $comment_ID, $comment); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment. |
| 53 | 53 | */ |
| 54 | -function comment_author( $comment_ID = 0 ) { |
|
| 55 | - $author = get_comment_author( $comment_ID ); |
|
| 54 | +function comment_author($comment_ID = 0) { |
|
| 55 | + $author = get_comment_author($comment_ID); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Filter the comment author's name for display. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param string $author The comment author's username. |
| 64 | 64 | * @param int $comment_ID The comment ID. |
| 65 | 65 | */ |
| 66 | - echo apply_filters( 'comment_author', $author, $comment_ID ); |
|
| 66 | + echo apply_filters('comment_author', $author, $comment_ID); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param int $comment_ID Optional. The ID of the comment for which to get the author's email. Default current comment. |
| 75 | 75 | * @return string The current comment author's email |
| 76 | 76 | */ |
| 77 | -function get_comment_author_email( $comment_ID = 0 ) { |
|
| 78 | - $comment = get_comment( $comment_ID ); |
|
| 77 | +function get_comment_author_email($comment_ID = 0) { |
|
| 78 | + $comment = get_comment($comment_ID); |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Filter the comment author's returned email address. |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param int $comment_ID The comment ID. |
| 88 | 88 | * @param object $comment The comment object. |
| 89 | 89 | */ |
| 90 | - return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment_ID, $comment ); |
|
| 90 | + return apply_filters('get_comment_author_email', $comment->comment_author_email, $comment_ID, $comment); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param int $comment_ID Optional. The ID of the comment for which to print the author's email. Default current comment. |
| 105 | 105 | */ |
| 106 | -function comment_author_email( $comment_ID = 0 ) { |
|
| 107 | - $author_email = get_comment_author_email( $comment_ID ); |
|
| 106 | +function comment_author_email($comment_ID = 0) { |
|
| 107 | + $author_email = get_comment_author_email($comment_ID); |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Filter the comment author's email for display. |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $author_email The comment author's email address. |
| 116 | 116 | * @param int $comment_ID The comment ID. |
| 117 | 117 | */ |
| 118 | - echo apply_filters( 'author_email', $author_email, $comment_ID ); |
|
| 118 | + echo apply_filters('author_email', $author_email, $comment_ID); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @param string $before Optional. Text or HTML to display before the email link. Default empty. |
| 135 | 135 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 136 | 136 | */ |
| 137 | -function comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
|
| 138 | - if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) |
|
| 137 | +function comment_author_email_link($linktext = '', $before = '', $after = '') { |
|
| 138 | + if ($link = get_comment_author_email_link($linktext, $before, $after)) |
|
| 139 | 139 | echo $link; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | -function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
|
| 161 | +function get_comment_author_email_link($linktext = '', $before = '', $after = '') { |
|
| 162 | 162 | global $comment; |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @param string $comment_author_email The comment author's email address. |
| 174 | 174 | * @param object $comment The comment object. |
| 175 | 175 | */ |
| 176 | - $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); |
|
| 177 | - if ((!empty($email)) && ($email != '@')) { |
|
| 176 | + $email = apply_filters('comment_email', $comment->comment_author_email, $comment); |
|
| 177 | + if (( ! empty($email)) && ($email != '@')) { |
|
| 178 | 178 | $display = ($linktext != '') ? $linktext : $email; |
| 179 | 179 | $return = $before; |
| 180 | 180 | $return .= "<a href='mailto:$email'>$display</a>"; |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | * Default current comment. |
| 198 | 198 | * @return string The comment author name or HTML link for author's URL. |
| 199 | 199 | */ |
| 200 | -function get_comment_author_link( $comment_ID = 0 ) { |
|
| 201 | - $url = get_comment_author_url( $comment_ID ); |
|
| 202 | - $author = get_comment_author( $comment_ID ); |
|
| 200 | +function get_comment_author_link($comment_ID = 0) { |
|
| 201 | + $url = get_comment_author_url($comment_ID); |
|
| 202 | + $author = get_comment_author($comment_ID); |
|
| 203 | 203 | |
| 204 | - if ( empty( $url ) || 'http://' == $url ) |
|
| 204 | + if (empty($url) || 'http://' == $url) |
|
| 205 | 205 | $return = $author; |
| 206 | 206 | else |
| 207 | 207 | $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param string $author The comment author's username. |
| 218 | 218 | * @param int $comment_ID The comment ID. |
| 219 | 219 | */ |
| 220 | - return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID ); |
|
| 220 | + return apply_filters('get_comment_author_link', $return, $author, $comment_ID); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -228,8 +228,8 @@ discard block |
||
| 228 | 228 | * @param int $comment_ID ID of the comment for which to print the author's |
| 229 | 229 | * link. Default current comment. |
| 230 | 230 | */ |
| 231 | -function comment_author_link( $comment_ID = 0 ) { |
|
| 232 | - echo get_comment_author_link( $comment_ID ); |
|
| 231 | +function comment_author_link($comment_ID = 0) { |
|
| 232 | + echo get_comment_author_link($comment_ID); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * address. Default current comment. |
| 242 | 242 | * @return string Comment author's IP address. |
| 243 | 243 | */ |
| 244 | -function get_comment_author_IP( $comment_ID = 0 ) { |
|
| 245 | - $comment = get_comment( $comment_ID ); |
|
| 244 | +function get_comment_author_IP($comment_ID = 0) { |
|
| 245 | + $comment = get_comment($comment_ID); |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Filter the comment author's returned IP address. |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @param int $comment_ID The comment ID. |
| 255 | 255 | * @param object $comment The comment object. |
| 256 | 256 | */ |
| 257 | - return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment ); |
|
| 257 | + return apply_filters('get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | * @param int $comment_ID ID of the comment for which to print the author's IP |
| 266 | 266 | * address. Default current comment. |
| 267 | 267 | */ |
| 268 | -function comment_author_IP( $comment_ID = 0 ) { |
|
| 269 | - echo get_comment_author_IP( $comment_ID ); |
|
| 268 | +function comment_author_IP($comment_ID = 0) { |
|
| 269 | + echo get_comment_author_IP($comment_ID); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -278,10 +278,10 @@ discard block |
||
| 278 | 278 | * Default current comment. |
| 279 | 279 | * @return string |
| 280 | 280 | */ |
| 281 | -function get_comment_author_url( $comment_ID = 0 ) { |
|
| 282 | - $comment = get_comment( $comment_ID ); |
|
| 281 | +function get_comment_author_url($comment_ID = 0) { |
|
| 282 | + $comment = get_comment($comment_ID); |
|
| 283 | 283 | $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; |
| 284 | - $url = esc_url( $url, array('http', 'https') ); |
|
| 284 | + $url = esc_url($url, array('http', 'https')); |
|
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * Filter the comment author's URL. |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param int $comment_ID The comment ID. |
| 294 | 294 | * @param object $comment The comment object. |
| 295 | 295 | */ |
| 296 | - return apply_filters( 'get_comment_author_url', $url, $comment_ID, $comment ); |
|
| 296 | + return apply_filters('get_comment_author_url', $url, $comment_ID, $comment); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | /** |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | * @param int $comment_ID ID of the comment for which to print the author's URL. |
| 305 | 305 | * Default current comment. |
| 306 | 306 | */ |
| 307 | -function comment_author_url( $comment_ID = 0 ) { |
|
| 308 | - $author_url = get_comment_author_url( $comment_ID ); |
|
| 307 | +function comment_author_url($comment_ID = 0) { |
|
| 308 | + $author_url = get_comment_author_url($comment_ID); |
|
| 309 | 309 | |
| 310 | 310 | /** |
| 311 | 311 | * Filter the comment author's URL for display. |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * @param string $author_url The comment author's URL. |
| 317 | 317 | * @param int $comment_ID The comment ID. |
| 318 | 318 | */ |
| 319 | - echo apply_filters( 'comment_url', $author_url, $comment_ID ); |
|
| 319 | + echo apply_filters('comment_url', $author_url, $comment_ID); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | * Default empty. |
| 340 | 340 | * @return string The HTML link between the $before and $after parameters. |
| 341 | 341 | */ |
| 342 | -function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
| 342 | +function get_comment_author_url_link($linktext = '', $before = '', $after = '') { |
|
| 343 | 343 | $url = get_comment_author_url(); |
| 344 | 344 | $display = ($linktext != '') ? $linktext : $url; |
| 345 | - $display = str_replace( 'http://www.', '', $display ); |
|
| 346 | - $display = str_replace( 'http://', '', $display ); |
|
| 345 | + $display = str_replace('http://www.', '', $display); |
|
| 346 | + $display = str_replace('http://', '', $display); |
|
| 347 | 347 | |
| 348 | - if ( '/' == substr($display, -1) ) { |
|
| 348 | + if ('/' == substr($display, -1)) { |
|
| 349 | 349 | $display = substr($display, 0, -1); |
| 350 | 350 | } |
| 351 | 351 | |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @param string $return The HTML-formatted comment author URL link. |
| 360 | 360 | */ |
| 361 | - return apply_filters( 'get_comment_author_url_link', $return ); |
|
| 361 | + return apply_filters('get_comment_author_url_link', $return); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -373,8 +373,8 @@ discard block |
||
| 373 | 373 | * @param string $after Optional. Text or HTML to display after the email link. |
| 374 | 374 | * Default empty. |
| 375 | 375 | */ |
| 376 | -function comment_author_url_link( $linktext = '', $before = '', $after = '' ) { |
|
| 377 | - echo get_comment_author_url_link( $linktext, $before, $after ); |
|
| 376 | +function comment_author_url_link($linktext = '', $before = '', $after = '') { |
|
| 377 | + echo get_comment_author_url_link($linktext, $before, $after); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -390,10 +390,10 @@ discard block |
||
| 390 | 390 | * Default true. |
| 391 | 391 | * @return string|void |
| 392 | 392 | */ |
| 393 | -function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { |
|
| 393 | +function comment_class($class = '', $comment_id = null, $post_id = null, $echo = true) { |
|
| 394 | 394 | // Separates classes with a single space, collates classes for comment DIV |
| 395 | - $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; |
|
| 396 | - if ( $echo) |
|
| 395 | + $class = 'class="'.join(' ', get_comment_class($class, $comment_id, $post_id)).'"'; |
|
| 396 | + if ($echo) |
|
| 397 | 397 | echo $class; |
| 398 | 398 | else |
| 399 | 399 | return $class; |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 414 | 414 | * @return array An array of classes. |
| 415 | 415 | */ |
| 416 | -function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
|
| 416 | +function get_comment_class($class = '', $comment_id = null, $post_id = null) { |
|
| 417 | 417 | global $comment_alt, $comment_depth, $comment_thread_alt; |
| 418 | 418 | |
| 419 | 419 | $comment = get_comment($comment_id); |
@@ -421,28 +421,28 @@ discard block |
||
| 421 | 421 | $classes = array(); |
| 422 | 422 | |
| 423 | 423 | // Get the comment type (comment, trackback), |
| 424 | - $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; |
|
| 424 | + $classes[] = (empty($comment->comment_type)) ? 'comment' : $comment->comment_type; |
|
| 425 | 425 | |
| 426 | 426 | // Add classes for comment authors that are registered users. |
| 427 | - if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
|
| 427 | + if ($comment->user_id > 0 && $user = get_userdata($comment->user_id)) { |
|
| 428 | 428 | $classes[] = 'byuser'; |
| 429 | - $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
|
| 429 | + $classes[] = 'comment-author-'.sanitize_html_class($user->user_nicename, $comment->user_id); |
|
| 430 | 430 | // For comment authors who are the author of the post |
| 431 | - if ( $post = get_post($post_id) ) { |
|
| 432 | - if ( $comment->user_id === $post->post_author ) { |
|
| 431 | + if ($post = get_post($post_id)) { |
|
| 432 | + if ($comment->user_id === $post->post_author) { |
|
| 433 | 433 | $classes[] = 'bypostauthor'; |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( empty($comment_alt) ) |
|
| 438 | + if (empty($comment_alt)) |
|
| 439 | 439 | $comment_alt = 0; |
| 440 | - if ( empty($comment_depth) ) |
|
| 440 | + if (empty($comment_depth)) |
|
| 441 | 441 | $comment_depth = 1; |
| 442 | - if ( empty($comment_thread_alt) ) |
|
| 442 | + if (empty($comment_thread_alt)) |
|
| 443 | 443 | $comment_thread_alt = 0; |
| 444 | 444 | |
| 445 | - if ( $comment_alt % 2 ) { |
|
| 445 | + if ($comment_alt % 2) { |
|
| 446 | 446 | $classes[] = 'odd'; |
| 447 | 447 | $classes[] = 'alt'; |
| 448 | 448 | } else { |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | $comment_alt++; |
| 453 | 453 | |
| 454 | 454 | // Alt for top-level comments |
| 455 | - if ( 1 == $comment_depth ) { |
|
| 456 | - if ( $comment_thread_alt % 2 ) { |
|
| 455 | + if (1 == $comment_depth) { |
|
| 456 | + if ($comment_thread_alt % 2) { |
|
| 457 | 457 | $classes[] = 'thread-odd'; |
| 458 | 458 | $classes[] = 'thread-alt'; |
| 459 | 459 | } else { |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | $classes[] = "depth-$comment_depth"; |
| 466 | 466 | |
| 467 | - if ( !empty($class) ) { |
|
| 468 | - if ( !is_array( $class ) ) |
|
| 467 | + if ( ! empty($class)) { |
|
| 468 | + if ( ! is_array($class)) |
|
| 469 | 469 | $class = preg_split('#\s+#', $class); |
| 470 | 470 | $classes = array_merge($classes, $class); |
| 471 | 471 | } |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | * @param object $comment The comment |
| 484 | 484 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 485 | 485 | */ |
| 486 | - return apply_filters( 'comment_class', $classes, $class, $comment_id, $comment, $post_id ); |
|
| 486 | + return apply_filters('comment_class', $classes, $class, $comment_id, $comment, $post_id); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -495,9 +495,9 @@ discard block |
||
| 495 | 495 | * @param int $comment_ID ID of the comment for which to get the date. Default current comment. |
| 496 | 496 | * @return string The comment's date. |
| 497 | 497 | */ |
| 498 | -function get_comment_date( $d = '', $comment_ID = 0 ) { |
|
| 499 | - $comment = get_comment( $comment_ID ); |
|
| 500 | - if ( '' == $d ) |
|
| 498 | +function get_comment_date($d = '', $comment_ID = 0) { |
|
| 499 | + $comment = get_comment($comment_ID); |
|
| 500 | + if ('' == $d) |
|
| 501 | 501 | $date = mysql2date(get_option('date_format'), $comment->comment_date); |
| 502 | 502 | else |
| 503 | 503 | $date = mysql2date($d, $comment->comment_date); |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | * @param string $d The format of the date. |
| 511 | 511 | * @param object $comment The comment object. |
| 512 | 512 | */ |
| 513 | - return apply_filters( 'get_comment_date', $date, $d, $comment ); |
|
| 513 | + return apply_filters('get_comment_date', $date, $d, $comment); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -521,8 +521,8 @@ discard block |
||
| 521 | 521 | * @param string $d Optional. The format of the date. Default user's settings. |
| 522 | 522 | * @param int $comment_ID ID of the comment for which to print the date. Default current comment. |
| 523 | 523 | */ |
| 524 | -function comment_date( $d = '', $comment_ID = 0 ) { |
|
| 525 | - echo get_comment_date( $d, $comment_ID ); |
|
| 524 | +function comment_date($d = '', $comment_ID = 0) { |
|
| 525 | + echo get_comment_date($d, $comment_ID); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | * Default current comment. |
| 539 | 539 | * @return string The maybe truncated comment with 20 words or less. |
| 540 | 540 | */ |
| 541 | -function get_comment_excerpt( $comment_ID = 0 ) { |
|
| 542 | - $comment = get_comment( $comment_ID ); |
|
| 541 | +function get_comment_excerpt($comment_ID = 0) { |
|
| 542 | + $comment = get_comment($comment_ID); |
|
| 543 | 543 | $comment_text = strip_tags($comment->comment_content); |
| 544 | 544 | $blah = explode(' ', $comment_text); |
| 545 | 545 | |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | $excerpt = ''; |
| 555 | - for ($i=0; $i<$k; $i++) { |
|
| 556 | - $excerpt .= $blah[$i] . ' '; |
|
| 555 | + for ($i = 0; $i < $k; $i++) { |
|
| 556 | + $excerpt .= $blah[$i].' '; |
|
| 557 | 557 | } |
| 558 | 558 | $excerpt .= ($use_dotdotdot) ? '…' : ''; |
| 559 | 559 | |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | * @param int $comment_ID The comment ID. |
| 568 | 568 | * @param object $comment The comment object. |
| 569 | 569 | */ |
| 570 | - return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment ); |
|
| 570 | + return apply_filters('get_comment_excerpt', $excerpt, $comment_ID, $comment); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * @param int $comment_ID ID of the comment for which to print the excerpt. |
| 579 | 579 | * Default current comment. |
| 580 | 580 | */ |
| 581 | -function comment_excerpt( $comment_ID = 0 ) { |
|
| 581 | +function comment_excerpt($comment_ID = 0) { |
|
| 582 | 582 | $comment_excerpt = get_comment_excerpt($comment_ID); |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @param string $comment_excerpt The comment excerpt text. |
| 591 | 591 | * @param int $comment_ID The comment ID. |
| 592 | 592 | */ |
| 593 | - echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID ); |
|
| 593 | + echo apply_filters('comment_excerpt', $comment_excerpt, $comment_ID); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | * @param int $comment_ID The current comment ID. |
| 615 | 615 | * @param object $comment The comment object. |
| 616 | 616 | */ |
| 617 | - return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); |
|
| 617 | + return apply_filters('get_comment_ID', $comment->comment_ID, $comment); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
@@ -640,40 +640,40 @@ discard block |
||
| 640 | 640 | * @param array $args Optional. An array of arguments to override the defaults. |
| 641 | 641 | * @return string The permalink to the given comment. |
| 642 | 642 | */ |
| 643 | -function get_comment_link( $comment = null, $args = array() ) { |
|
| 643 | +function get_comment_link($comment = null, $args = array()) { |
|
| 644 | 644 | global $wp_rewrite, $in_comment_loop; |
| 645 | 645 | |
| 646 | 646 | $comment = get_comment($comment); |
| 647 | 647 | |
| 648 | 648 | // Backwards compat |
| 649 | - if ( ! is_array( $args ) ) { |
|
| 650 | - $args = array( 'page' => $args ); |
|
| 649 | + if ( ! is_array($args)) { |
|
| 650 | + $args = array('page' => $args); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
|
| 654 | - $args = wp_parse_args( $args, $defaults ); |
|
| 653 | + $defaults = array('type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => ''); |
|
| 654 | + $args = wp_parse_args($args, $defaults); |
|
| 655 | 655 | |
| 656 | - if ( '' === $args['per_page'] && get_option('page_comments') ) |
|
| 656 | + if ('' === $args['per_page'] && get_option('page_comments')) |
|
| 657 | 657 | $args['per_page'] = get_option('comments_per_page'); |
| 658 | 658 | |
| 659 | - if ( empty($args['per_page']) ) { |
|
| 659 | + if (empty($args['per_page'])) { |
|
| 660 | 660 | $args['per_page'] = 0; |
| 661 | 661 | $args['page'] = 0; |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - if ( $args['per_page'] ) { |
|
| 665 | - if ( '' == $args['page'] ) |
|
| 666 | - $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); |
|
| 664 | + if ($args['per_page']) { |
|
| 665 | + if ('' == $args['page']) |
|
| 666 | + $args['page'] = ( ! empty($in_comment_loop)) ? get_query_var('cpage') : get_page_of_comment($comment->comment_ID, $args); |
|
| 667 | 667 | |
| 668 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 669 | - $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' ); |
|
| 668 | + if ($wp_rewrite->using_permalinks()) |
|
| 669 | + $link = user_trailingslashit(trailingslashit(get_permalink($comment->comment_post_ID)).$wp_rewrite->comments_pagination_base.'-'.$args['page'], 'comment'); |
|
| 670 | 670 | else |
| 671 | - $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); |
|
| 671 | + $link = add_query_arg('cpage', $args['page'], get_permalink($comment->comment_post_ID)); |
|
| 672 | 672 | } else { |
| 673 | - $link = get_permalink( $comment->comment_post_ID ); |
|
| 673 | + $link = get_permalink($comment->comment_post_ID); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - $link = $link . '#comment-' . $comment->comment_ID; |
|
| 676 | + $link = $link.'#comment-'.$comment->comment_ID; |
|
| 677 | 677 | /** |
| 678 | 678 | * Filter the returned single comment permalink. |
| 679 | 679 | * |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | * @param object $comment The current comment object. |
| 686 | 686 | * @param array $args An array of arguments to override the defaults. |
| 687 | 687 | */ |
| 688 | - return apply_filters( 'get_comment_link', $link, $comment, $args ); |
|
| 688 | + return apply_filters('get_comment_link', $link, $comment, $args); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -696,8 +696,8 @@ discard block |
||
| 696 | 696 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
| 697 | 697 | * @return string The link to the comments. |
| 698 | 698 | */ |
| 699 | -function get_comments_link( $post_id = 0 ) { |
|
| 700 | - $comments_link = get_permalink( $post_id ) . '#comments'; |
|
| 699 | +function get_comments_link($post_id = 0) { |
|
| 700 | + $comments_link = get_permalink($post_id).'#comments'; |
|
| 701 | 701 | /** |
| 702 | 702 | * Filter the returned post comments permalink. |
| 703 | 703 | * |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | * @param string $comments_link Post comments permalink with '#comments' appended. |
| 707 | 707 | * @param int|WP_Post $post_id Post ID or WP_Post object. |
| 708 | 708 | */ |
| 709 | - return apply_filters( 'get_comments_link', $comments_link, $post_id ); |
|
| 709 | + return apply_filters('get_comments_link', $comments_link, $post_id); |
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | /** |
@@ -717,12 +717,12 @@ discard block |
||
| 717 | 717 | * @param string $deprecated Not Used. |
| 718 | 718 | * @param string $deprecated_2 Not Used. |
| 719 | 719 | */ |
| 720 | -function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
|
| 721 | - if ( !empty( $deprecated ) ) |
|
| 722 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 723 | - if ( !empty( $deprecated_2 ) ) |
|
| 724 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 725 | - echo esc_url( get_comments_link() ); |
|
| 720 | +function comments_link($deprecated = '', $deprecated_2 = '') { |
|
| 721 | + if ( ! empty($deprecated)) |
|
| 722 | + _deprecated_argument(__FUNCTION__, '0.72'); |
|
| 723 | + if ( ! empty($deprecated_2)) |
|
| 724 | + _deprecated_argument(__FUNCTION__, '1.3'); |
|
| 725 | + echo esc_url(get_comments_link()); |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
@@ -733,10 +733,10 @@ discard block |
||
| 733 | 733 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
| 734 | 734 | * @return int The number of comments a post has. |
| 735 | 735 | */ |
| 736 | -function get_comments_number( $post_id = 0 ) { |
|
| 737 | - $post = get_post( $post_id ); |
|
| 736 | +function get_comments_number($post_id = 0) { |
|
| 737 | + $post = get_post($post_id); |
|
| 738 | 738 | |
| 739 | - if ( ! $post ) { |
|
| 739 | + if ( ! $post) { |
|
| 740 | 740 | $count = 0; |
| 741 | 741 | } else { |
| 742 | 742 | $count = $post->comment_count; |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | * @param int $count Number of comments a post has. |
| 752 | 752 | * @param int $post_id Post ID. |
| 753 | 753 | */ |
| 754 | - return apply_filters( 'get_comments_number', $count, $post_id ); |
|
| 754 | + return apply_filters('get_comments_number', $count, $post_id); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | /** |
@@ -764,11 +764,11 @@ discard block |
||
| 764 | 764 | * @param string $more Optional. Text for more than one comment. Default false. |
| 765 | 765 | * @param string $deprecated Not used. |
| 766 | 766 | */ |
| 767 | -function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) { |
|
| 768 | - if ( ! empty( $deprecated ) ) { |
|
| 769 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 767 | +function comments_number($zero = false, $one = false, $more = false, $deprecated = '') { |
|
| 768 | + if ( ! empty($deprecated)) { |
|
| 769 | + _deprecated_argument(__FUNCTION__, '1.3'); |
|
| 770 | 770 | } |
| 771 | - echo get_comments_number_text( $zero, $one, $more ); |
|
| 771 | + echo get_comments_number_text($zero, $one, $more); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | /** |
@@ -780,15 +780,15 @@ discard block |
||
| 780 | 780 | * @param string $one Optional. Text for one comment. Default false. |
| 781 | 781 | * @param string $more Optional. Text for more than one comment. Default false. |
| 782 | 782 | */ |
| 783 | -function get_comments_number_text( $zero = false, $one = false, $more = false ) { |
|
| 783 | +function get_comments_number_text($zero = false, $one = false, $more = false) { |
|
| 784 | 784 | $number = get_comments_number(); |
| 785 | 785 | |
| 786 | - if ( $number > 1 ) { |
|
| 787 | - $output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments' ) : $more ); |
|
| 788 | - } elseif ( $number == 0 ) { |
|
| 789 | - $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; |
|
| 786 | + if ($number > 1) { |
|
| 787 | + $output = str_replace('%', number_format_i18n($number), (false === $more) ? __('% Comments') : $more); |
|
| 788 | + } elseif ($number == 0) { |
|
| 789 | + $output = (false === $zero) ? __('No Comments') : $zero; |
|
| 790 | 790 | } else { // must be one |
| 791 | - $output = ( false === $one ) ? __( '1 Comment' ) : $one; |
|
| 791 | + $output = (false === $one) ? __('1 Comment') : $one; |
|
| 792 | 792 | } |
| 793 | 793 | /** |
| 794 | 794 | * Filter the comments count for display. |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * is equal to 0, 1, or 1+. |
| 802 | 802 | * @param int $number The number of post comments. |
| 803 | 803 | */ |
| 804 | - return apply_filters( 'comments_number', $output, $number ); |
|
| 804 | + return apply_filters('comments_number', $output, $number); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -815,8 +815,8 @@ discard block |
||
| 815 | 815 | * @param array $args Optional. An array of arguments. Default empty. |
| 816 | 816 | * @return string The comment content. |
| 817 | 817 | */ |
| 818 | -function get_comment_text( $comment_ID = 0, $args = array() ) { |
|
| 819 | - $comment = get_comment( $comment_ID ); |
|
| 818 | +function get_comment_text($comment_ID = 0, $args = array()) { |
|
| 819 | + $comment = get_comment($comment_ID); |
|
| 820 | 820 | |
| 821 | 821 | /** |
| 822 | 822 | * Filter the text of a comment. |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | * @param object $comment The comment object. |
| 830 | 830 | * @param array $args An array of arguments. |
| 831 | 831 | */ |
| 832 | - return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); |
|
| 832 | + return apply_filters('get_comment_text', $comment->comment_content, $comment, $args); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
@@ -842,10 +842,10 @@ discard block |
||
| 842 | 842 | * @param int $comment_ID ID of the comment for which to print the text. Default 0. |
| 843 | 843 | * @param array $args Optional. An array of arguments. Default empty array. Default empty. |
| 844 | 844 | */ |
| 845 | -function comment_text( $comment_ID = 0, $args = array() ) { |
|
| 846 | - $comment = get_comment( $comment_ID ); |
|
| 845 | +function comment_text($comment_ID = 0, $args = array()) { |
|
| 846 | + $comment = get_comment($comment_ID); |
|
| 847 | 847 | |
| 848 | - $comment_text = get_comment_text( $comment_ID , $args ); |
|
| 848 | + $comment_text = get_comment_text($comment_ID, $args); |
|
| 849 | 849 | /** |
| 850 | 850 | * Filter the text of a comment to be displayed. |
| 851 | 851 | * |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | * @param object $comment The comment object. |
| 858 | 858 | * @param array $args An array of arguments. |
| 859 | 859 | */ |
| 860 | - echo apply_filters( 'comment_text', $comment_text, $comment, $args ); |
|
| 860 | + echo apply_filters('comment_text', $comment_text, $comment, $args); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | /** |
@@ -873,10 +873,10 @@ discard block |
||
| 873 | 873 | * Default true. |
| 874 | 874 | * @return string The formatted time. |
| 875 | 875 | */ |
| 876 | -function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
|
| 876 | +function get_comment_time($d = '', $gmt = false, $translate = true) { |
|
| 877 | 877 | global $comment; |
| 878 | 878 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
| 879 | - if ( '' == $d ) |
|
| 879 | + if ('' == $d) |
|
| 880 | 880 | $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
| 881 | 881 | else |
| 882 | 882 | $date = mysql2date($d, $comment_date, $translate); |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | * @param bool $translate Whether the time is translated. |
| 893 | 893 | * @param object $comment The comment object. |
| 894 | 894 | */ |
| 895 | - return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment ); |
|
| 895 | + return apply_filters('get_comment_time', $date, $d, $gmt, $translate, $comment); |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /** |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | * |
| 903 | 903 | * @param string $d Optional. The format of the time. Default user's settings. |
| 904 | 904 | */ |
| 905 | -function comment_time( $d = '' ) { |
|
| 905 | +function comment_time($d = '') { |
|
| 906 | 906 | echo get_comment_time($d); |
| 907 | 907 | } |
| 908 | 908 | |
@@ -914,9 +914,9 @@ discard block |
||
| 914 | 914 | * @param int $comment_ID ID of the comment for which to get the type. Default current comment. |
| 915 | 915 | * @return string The comment type. |
| 916 | 916 | */ |
| 917 | -function get_comment_type( $comment_ID = 0 ) { |
|
| 918 | - $comment = get_comment( $comment_ID ); |
|
| 919 | - if ( '' == $comment->comment_type ) |
|
| 917 | +function get_comment_type($comment_ID = 0) { |
|
| 918 | + $comment = get_comment($comment_ID); |
|
| 919 | + if ('' == $comment->comment_type) |
|
| 920 | 920 | $comment->comment_type = 'comment'; |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | * @param int $comment_ID The comment ID. |
| 930 | 930 | * @param object $comment The comment object. |
| 931 | 931 | */ |
| 932 | - return apply_filters( 'get_comment_type', $comment->comment_type, $comment_ID, $comment ); |
|
| 932 | + return apply_filters('get_comment_type', $comment->comment_type, $comment_ID, $comment); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | /** |
@@ -941,12 +941,12 @@ discard block |
||
| 941 | 941 | * @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
| 942 | 942 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
| 943 | 943 | */ |
| 944 | -function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
|
| 945 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
| 946 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
| 947 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
| 944 | +function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt = false) { |
|
| 945 | + if (false === $commenttxt) $commenttxt = _x('Comment', 'noun'); |
|
| 946 | + if (false === $trackbacktxt) $trackbacktxt = __('Trackback'); |
|
| 947 | + if (false === $pingbacktxt) $pingbacktxt = __('Pingback'); |
|
| 948 | 948 | $type = get_comment_type(); |
| 949 | - switch( $type ) { |
|
| 949 | + switch ($type) { |
|
| 950 | 950 | case 'trackback' : |
| 951 | 951 | echo $trackbacktxt; |
| 952 | 952 | break; |
@@ -970,10 +970,10 @@ discard block |
||
| 970 | 970 | * @return string The trackback URL after being filtered. |
| 971 | 971 | */ |
| 972 | 972 | function get_trackback_url() { |
| 973 | - if ( '' != get_option('permalink_structure') ) |
|
| 974 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 973 | + if ('' != get_option('permalink_structure')) |
|
| 974 | + $tb_url = trailingslashit(get_permalink()).user_trailingslashit('trackback', 'single_trackback'); |
|
| 975 | 975 | else |
| 976 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 976 | + $tb_url = get_option('siteurl').'/wp-trackback.php?p='.get_the_ID(); |
|
| 977 | 977 | |
| 978 | 978 | /** |
| 979 | 979 | * Filter the returned trackback URL. |
@@ -982,7 +982,7 @@ discard block |
||
| 982 | 982 | * |
| 983 | 983 | * @param string $tb_url The trackback URL. |
| 984 | 984 | */ |
| 985 | - return apply_filters( 'trackback_url', $tb_url ); |
|
| 985 | + return apply_filters('trackback_url', $tb_url); |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -994,10 +994,10 @@ discard block |
||
| 994 | 994 | * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
| 995 | 995 | * for the result instead. |
| 996 | 996 | */ |
| 997 | -function trackback_url( $deprecated_echo = true ) { |
|
| 998 | - if ( $deprecated_echo !== true ) |
|
| 999 | - _deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') ); |
|
| 1000 | - if ( $deprecated_echo ) |
|
| 997 | +function trackback_url($deprecated_echo = true) { |
|
| 998 | + if ($deprecated_echo !== true) |
|
| 999 | + _deprecated_argument(__FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.')); |
|
| 1000 | + if ($deprecated_echo) |
|
| 1001 | 1001 | echo get_trackback_url(); |
| 1002 | 1002 | else |
| 1003 | 1003 | return get_trackback_url(); |
@@ -1012,12 +1012,12 @@ discard block |
||
| 1012 | 1012 | * |
| 1013 | 1013 | * @param int $deprecated Not used (Was $timezone = 0). |
| 1014 | 1014 | */ |
| 1015 | -function trackback_rdf( $deprecated = '' ) { |
|
| 1016 | - if ( ! empty( $deprecated ) ) { |
|
| 1017 | - _deprecated_argument( __FUNCTION__, '2.5' ); |
|
| 1015 | +function trackback_rdf($deprecated = '') { |
|
| 1016 | + if ( ! empty($deprecated)) { |
|
| 1017 | + _deprecated_argument(__FUNCTION__, '2.5'); |
|
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) { |
|
| 1020 | + if (isset($_SERVER['HTTP_USER_AGENT']) && false !== stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) { |
|
| 1021 | 1021 | return; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
@@ -1043,11 +1043,11 @@ discard block |
||
| 1043 | 1043 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 1044 | 1044 | * @return bool True if the comments are open. |
| 1045 | 1045 | */ |
| 1046 | -function comments_open( $post_id = null ) { |
|
| 1046 | +function comments_open($post_id = null) { |
|
| 1047 | 1047 | |
| 1048 | 1048 | $_post = get_post($post_id); |
| 1049 | 1049 | |
| 1050 | - $open = ( 'open' == $_post->comment_status ); |
|
| 1050 | + $open = ('open' == $_post->comment_status); |
|
| 1051 | 1051 | |
| 1052 | 1052 | /** |
| 1053 | 1053 | * Filter whether the current post is open for comments. |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | * @param bool $open Whether the current post is open for comments. |
| 1058 | 1058 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 1059 | 1059 | */ |
| 1060 | - return apply_filters( 'comments_open', $open, $post_id ); |
|
| 1060 | + return apply_filters('comments_open', $open, $post_id); |
|
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | /** |
@@ -1068,11 +1068,11 @@ discard block |
||
| 1068 | 1068 | * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
| 1069 | 1069 | * @return bool True if pings are accepted |
| 1070 | 1070 | */ |
| 1071 | -function pings_open( $post_id = null ) { |
|
| 1071 | +function pings_open($post_id = null) { |
|
| 1072 | 1072 | |
| 1073 | 1073 | $_post = get_post($post_id); |
| 1074 | 1074 | |
| 1075 | - $open = ( 'open' == $_post->ping_status ); |
|
| 1075 | + $open = ('open' == $_post->ping_status); |
|
| 1076 | 1076 | |
| 1077 | 1077 | /** |
| 1078 | 1078 | * Filter whether the current post is open for pings. |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | * @param bool $open Whether the current post is open for pings. |
| 1083 | 1083 | * @param int|WP_Post $post_id The post ID or WP_Post object. |
| 1084 | 1084 | */ |
| 1085 | - return apply_filters( 'pings_open', $open, $post_id ); |
|
| 1085 | + return apply_filters('pings_open', $open, $post_id); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1103,8 +1103,8 @@ discard block |
||
| 1103 | 1103 | $post = get_post(); |
| 1104 | 1104 | $post_id = $post ? $post->ID : 0; |
| 1105 | 1105 | |
| 1106 | - if ( current_user_can( 'unfiltered_html' ) ) { |
|
| 1107 | - wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); |
|
| 1106 | + if (current_user_can('unfiltered_html')) { |
|
| 1107 | + wp_nonce_field('unfiltered-html-comment_'.$post_id, '_wp_unfiltered_html_comment_disabled', false); |
|
| 1108 | 1108 | echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; |
| 1109 | 1109 | } |
| 1110 | 1110 | } |
@@ -1143,13 +1143,13 @@ discard block |
||
| 1143 | 1143 | * @param bool $separate_comments Optional. Whether to separate the comments by comment type. |
| 1144 | 1144 | * Default false. |
| 1145 | 1145 | */ |
| 1146 | -function comments_template( $file = '/comments.php', $separate_comments = false ) { |
|
| 1146 | +function comments_template($file = '/comments.php', $separate_comments = false) { |
|
| 1147 | 1147 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
| 1148 | 1148 | |
| 1149 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
| 1149 | + if ( ! (is_single() || is_page() || $withcomments) || empty($post)) |
|
| 1150 | 1150 | return; |
| 1151 | 1151 | |
| 1152 | - if ( empty($file) ) |
|
| 1152 | + if (empty($file)) |
|
| 1153 | 1153 | $file = '/comments.php'; |
| 1154 | 1154 | |
| 1155 | 1155 | $req = get_option('require_name_email'); |
@@ -1183,13 +1183,13 @@ discard block |
||
| 1183 | 1183 | 'post_id' => $post->ID, |
| 1184 | 1184 | ); |
| 1185 | 1185 | |
| 1186 | - if ( $user_ID ) { |
|
| 1187 | - $comment_args['include_unapproved'] = array( $user_ID ); |
|
| 1188 | - } elseif ( ! empty( $comment_author_email ) ) { |
|
| 1189 | - $comment_args['include_unapproved'] = array( $comment_author_email ); |
|
| 1186 | + if ($user_ID) { |
|
| 1187 | + $comment_args['include_unapproved'] = array($user_ID); |
|
| 1188 | + } elseif ( ! empty($comment_author_email)) { |
|
| 1189 | + $comment_args['include_unapproved'] = array($comment_author_email); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | |
| 1192 | - $comments = get_comments( $comment_args ); |
|
| 1192 | + $comments = get_comments($comment_args); |
|
| 1193 | 1193 | |
| 1194 | 1194 | /** |
| 1195 | 1195 | * Filter the comments array. |
@@ -1199,25 +1199,25 @@ discard block |
||
| 1199 | 1199 | * @param array $comments Array of comments supplied to the comments template. |
| 1200 | 1200 | * @param int $post_ID Post ID. |
| 1201 | 1201 | */ |
| 1202 | - $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); |
|
| 1202 | + $wp_query->comments = apply_filters('comments_array', $comments, $post->ID); |
|
| 1203 | 1203 | $comments = &$wp_query->comments; |
| 1204 | 1204 | $wp_query->comment_count = count($wp_query->comments); |
| 1205 | 1205 | |
| 1206 | - if ( $separate_comments ) { |
|
| 1206 | + if ($separate_comments) { |
|
| 1207 | 1207 | $wp_query->comments_by_type = separate_comments($comments); |
| 1208 | 1208 | $comments_by_type = &$wp_query->comments_by_type; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | $overridden_cpage = false; |
| 1212 | - if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
|
| 1213 | - set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
| 1212 | + if ('' == get_query_var('cpage') && get_option('page_comments')) { |
|
| 1213 | + set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); |
|
| 1214 | 1214 | $overridden_cpage = true; |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
| 1217 | + if ( ! defined('COMMENTS_TEMPLATE')) |
|
| 1218 | 1218 | define('COMMENTS_TEMPLATE', true); |
| 1219 | 1219 | |
| 1220 | - $theme_template = STYLESHEETPATH . $file; |
|
| 1220 | + $theme_template = STYLESHEETPATH.$file; |
|
| 1221 | 1221 | /** |
| 1222 | 1222 | * Filter the path to the theme template file used for the comments template. |
| 1223 | 1223 | * |
@@ -1225,13 +1225,13 @@ discard block |
||
| 1225 | 1225 | * |
| 1226 | 1226 | * @param string $theme_template The path to the theme template file. |
| 1227 | 1227 | */ |
| 1228 | - $include = apply_filters( 'comments_template', $theme_template ); |
|
| 1229 | - if ( file_exists( $include ) ) |
|
| 1230 | - require( $include ); |
|
| 1231 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
| 1232 | - require( TEMPLATEPATH . $file ); |
|
| 1228 | + $include = apply_filters('comments_template', $theme_template); |
|
| 1229 | + if (file_exists($include)) |
|
| 1230 | + require($include); |
|
| 1231 | + elseif (file_exists(TEMPLATEPATH.$file)) |
|
| 1232 | + require(TEMPLATEPATH.$file); |
|
| 1233 | 1233 | else // Backward compat code will be removed in a future release |
| 1234 | - require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
|
| 1234 | + require(ABSPATH.WPINC.'/theme-compat/comments.php'); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1252,11 +1252,11 @@ discard block |
||
| 1252 | 1252 | * @param int $height Optional. The height of the popup window. Default 400. |
| 1253 | 1253 | * @param string $file Optional. Sets the location of the popup window. |
| 1254 | 1254 | */ |
| 1255 | -function comments_popup_script( $width = 400, $height = 400, $file = '' ) { |
|
| 1255 | +function comments_popup_script($width = 400, $height = 400, $file = '') { |
|
| 1256 | 1256 | global $wpcommentspopupfile, $wpcommentsjavascript; |
| 1257 | 1257 | |
| 1258 | 1258 | if (empty ($file)) { |
| 1259 | - $wpcommentspopupfile = ''; // Use the index. |
|
| 1259 | + $wpcommentspopupfile = ''; // Use the index. |
|
| 1260 | 1260 | } else { |
| 1261 | 1261 | $wpcommentspopupfile = $file; |
| 1262 | 1262 | } |
@@ -1286,61 +1286,61 @@ discard block |
||
| 1286 | 1286 | * @param string $none Optional. String to display when comments have been turned off. |
| 1287 | 1287 | * Default false. |
| 1288 | 1288 | */ |
| 1289 | -function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
|
| 1289 | +function comments_popup_link($zero = false, $one = false, $more = false, $css_class = '', $none = false) { |
|
| 1290 | 1290 | global $wpcommentspopupfile, $wpcommentsjavascript; |
| 1291 | 1291 | |
| 1292 | 1292 | $id = get_the_ID(); |
| 1293 | 1293 | $title = get_the_title(); |
| 1294 | - $number = get_comments_number( $id ); |
|
| 1294 | + $number = get_comments_number($id); |
|
| 1295 | 1295 | |
| 1296 | - if ( false === $zero ) { |
|
| 1296 | + if (false === $zero) { |
|
| 1297 | 1297 | /* translators: %s: post title */ |
| 1298 | - $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1298 | + $zero = sprintf(__('No Comments<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | - if ( false === $one ) { |
|
| 1301 | + if (false === $one) { |
|
| 1302 | 1302 | /* translators: %s: post title */ |
| 1303 | - $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1303 | + $one = sprintf(__('1 Comment<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | - if ( false === $more ) { |
|
| 1306 | + if (false === $more) { |
|
| 1307 | 1307 | /* translators: 1: Number of comments 2: post title */ |
| 1308 | - $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number ); |
|
| 1309 | - $more = sprintf( $more, number_format_i18n( $number ), $title ); |
|
| 1308 | + $more = _n('%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number); |
|
| 1309 | + $more = sprintf($more, number_format_i18n($number), $title); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | - if ( false === $none ) { |
|
| 1312 | + if (false === $none) { |
|
| 1313 | 1313 | /* translators: %s: post title */ |
| 1314 | - $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
|
| 1314 | + $none = sprintf(__('Comments Off<span class="screen-reader-text"> on %s</span>'), $title); |
|
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | - if ( 0 == $number && !comments_open() && !pings_open() ) { |
|
| 1318 | - echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; |
|
| 1317 | + if (0 == $number && ! comments_open() && ! pings_open()) { |
|
| 1318 | + echo '<span'.(( ! empty($css_class)) ? ' class="'.esc_attr($css_class).'"' : '').'>'.$none.'</span>'; |
|
| 1319 | 1319 | return; |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | - if ( post_password_required() ) { |
|
| 1323 | - _e( 'Enter your password to view comments.' ); |
|
| 1322 | + if (post_password_required()) { |
|
| 1323 | + _e('Enter your password to view comments.'); |
|
| 1324 | 1324 | return; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | 1327 | echo '<a href="'; |
| 1328 | - if ( $wpcommentsjavascript ) { |
|
| 1329 | - if ( empty( $wpcommentspopupfile ) ) |
|
| 1328 | + if ($wpcommentsjavascript) { |
|
| 1329 | + if (empty($wpcommentspopupfile)) |
|
| 1330 | 1330 | $home = home_url(); |
| 1331 | 1331 | else |
| 1332 | 1332 | $home = get_option('siteurl'); |
| 1333 | - echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; |
|
| 1333 | + echo $home.'/'.$wpcommentspopupfile.'?comments_popup='.$id; |
|
| 1334 | 1334 | echo '" onclick="wpopen(this.href); return false"'; |
| 1335 | 1335 | } else { // if comments_popup_script() is not in the template, display simple comment link |
| 1336 | - if ( 0 == $number ) |
|
| 1337 | - echo get_permalink() . '#respond'; |
|
| 1336 | + if (0 == $number) |
|
| 1337 | + echo get_permalink().'#respond'; |
|
| 1338 | 1338 | else |
| 1339 | 1339 | comments_link(); |
| 1340 | 1340 | echo '"'; |
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | - if ( !empty( $css_class ) ) { |
|
| 1343 | + if ( ! empty($css_class)) { |
|
| 1344 | 1344 | echo ' class="'.$css_class.'" '; |
| 1345 | 1345 | } |
| 1346 | 1346 | |
@@ -1352,10 +1352,10 @@ discard block |
||
| 1352 | 1352 | * |
| 1353 | 1353 | * @param string $attributes The comments popup link attributes. Default empty. |
| 1354 | 1354 | */ |
| 1355 | - echo apply_filters( 'comments_popup_link_attributes', $attributes ); |
|
| 1355 | + echo apply_filters('comments_popup_link_attributes', $attributes); |
|
| 1356 | 1356 | |
| 1357 | 1357 | echo '>'; |
| 1358 | - comments_number( $zero, $one, $more ); |
|
| 1358 | + comments_number($zero, $one, $more); |
|
| 1359 | 1359 | echo '</a>'; |
| 1360 | 1360 | } |
| 1361 | 1361 | |
@@ -1385,33 +1385,33 @@ discard block |
||
| 1385 | 1385 | * Default current post. |
| 1386 | 1386 | * @return void|false|string Link to show comment form, if successful. False, if comments are closed. |
| 1387 | 1387 | */ |
| 1388 | -function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
|
| 1388 | +function get_comment_reply_link($args = array(), $comment = null, $post = null) { |
|
| 1389 | 1389 | $defaults = array( |
| 1390 | 1390 | 'add_below' => 'comment', |
| 1391 | 1391 | 'respond_id' => 'respond', |
| 1392 | - 'reply_text' => __( 'Reply' ), |
|
| 1393 | - 'reply_to_text' => __( 'Reply to %s' ), |
|
| 1394 | - 'login_text' => __( 'Log in to Reply' ), |
|
| 1392 | + 'reply_text' => __('Reply'), |
|
| 1393 | + 'reply_to_text' => __('Reply to %s'), |
|
| 1394 | + 'login_text' => __('Log in to Reply'), |
|
| 1395 | 1395 | 'depth' => 0, |
| 1396 | 1396 | 'before' => '', |
| 1397 | 1397 | 'after' => '' |
| 1398 | 1398 | ); |
| 1399 | 1399 | |
| 1400 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1400 | + $args = wp_parse_args($args, $defaults); |
|
| 1401 | 1401 | |
| 1402 | - if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
|
| 1402 | + if (0 == $args['depth'] || $args['max_depth'] <= $args['depth']) { |
|
| 1403 | 1403 | return; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - $comment = get_comment( $comment ); |
|
| 1406 | + $comment = get_comment($comment); |
|
| 1407 | 1407 | |
| 1408 | - if ( empty( $post ) ) { |
|
| 1408 | + if (empty($post)) { |
|
| 1409 | 1409 | $post = $comment->comment_post_ID; |
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | - $post = get_post( $post ); |
|
| 1412 | + $post = get_post($post); |
|
| 1413 | 1413 | |
| 1414 | - if ( ! comments_open( $post->ID ) ) { |
|
| 1414 | + if ( ! comments_open($post->ID)) { |
|
| 1415 | 1415 | return false; |
| 1416 | 1416 | } |
| 1417 | 1417 | |
@@ -1425,22 +1425,22 @@ discard block |
||
| 1425 | 1425 | * @param object $comment The object of the comment being replied to. |
| 1426 | 1426 | * @param WP_Post $post The {@see WP_Post} object. |
| 1427 | 1427 | */ |
| 1428 | - $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
|
| 1428 | + $args = apply_filters('comment_reply_link_args', $args, $comment, $post); |
|
| 1429 | 1429 | |
| 1430 | - if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
|
| 1431 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1432 | - esc_url( wp_login_url( get_permalink() ) ), |
|
| 1430 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
| 1431 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1432 | + esc_url(wp_login_url(get_permalink())), |
|
| 1433 | 1433 | $args['login_text'] |
| 1434 | 1434 | ); |
| 1435 | 1435 | } else { |
| 1436 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
| 1436 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
|
| 1437 | 1437 | $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID |
| 1438 | 1438 | ); |
| 1439 | 1439 | |
| 1440 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
| 1441 | - esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'], |
|
| 1440 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
|
| 1441 | + esc_url(add_query_arg('replytocom', $comment->comment_ID, get_permalink($post->ID)))."#".$args['respond_id'], |
|
| 1442 | 1442 | $onclick, |
| 1443 | - esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
|
| 1443 | + esc_attr(sprintf($args['reply_to_text'], $comment->comment_author)), |
|
| 1444 | 1444 | $args['reply_text'] |
| 1445 | 1445 | ); |
| 1446 | 1446 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
| 1454 | 1454 | * @param object $comment The object of the comment being replied. |
| 1455 | 1455 | * @param WP_Post $post The WP_Post object. |
| 1456 | 1456 | */ |
| 1457 | - return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); |
|
| 1457 | + return apply_filters('comment_reply_link', $args['before'].$link.$args['after'], $args, $comment, $post); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | /** |
@@ -1511,27 +1511,27 @@ discard block |
||
| 1511 | 1511 | |
| 1512 | 1512 | $post = get_post($post); |
| 1513 | 1513 | |
| 1514 | - if ( ! comments_open( $post->ID ) ) { |
|
| 1514 | + if ( ! comments_open($post->ID)) { |
|
| 1515 | 1515 | return false; |
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | - if ( get_option('comment_registration') && ! is_user_logged_in() ) { |
|
| 1519 | - $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1520 | - wp_login_url( get_permalink() ), |
|
| 1518 | + if (get_option('comment_registration') && ! is_user_logged_in()) { |
|
| 1519 | + $link = sprintf('<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
|
| 1520 | + wp_login_url(get_permalink()), |
|
| 1521 | 1521 | $args['login_text'] |
| 1522 | 1522 | ); |
| 1523 | 1523 | } else { |
| 1524 | - $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
| 1524 | + $onclick = sprintf('return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
| 1525 | 1525 | $args['add_below'], $post->ID, $args['respond_id'] |
| 1526 | 1526 | ); |
| 1527 | 1527 | |
| 1528 | - $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
| 1529 | - get_permalink( $post->ID ) . '#' . $args['respond_id'], |
|
| 1528 | + $link = sprintf("<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
|
| 1529 | + get_permalink($post->ID).'#'.$args['respond_id'], |
|
| 1530 | 1530 | $onclick, |
| 1531 | 1531 | $args['reply_text'] |
| 1532 | 1532 | ); |
| 1533 | 1533 | } |
| 1534 | - $formatted_link = $args['before'] . $link . $args['after']; |
|
| 1534 | + $formatted_link = $args['before'].$link.$args['after']; |
|
| 1535 | 1535 | /** |
| 1536 | 1536 | * Filter the formatted post comments link HTML. |
| 1537 | 1537 | * |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | * @param string $formatted The HTML-formatted post comments link. |
| 1541 | 1541 | * @param int|WP_Post $post The post ID or WP_Post object. |
| 1542 | 1542 | */ |
| 1543 | - return apply_filters( 'post_comments_link', $formatted_link, $post ); |
|
| 1543 | + return apply_filters('post_comments_link', $formatted_link, $post); |
|
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | /** |
@@ -1567,14 +1567,14 @@ discard block |
||
| 1567 | 1567 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
| 1568 | 1568 | * @return string |
| 1569 | 1569 | */ |
| 1570 | -function get_cancel_comment_reply_link( $text = '' ) { |
|
| 1571 | - if ( empty($text) ) |
|
| 1570 | +function get_cancel_comment_reply_link($text = '') { |
|
| 1571 | + if (empty($text)) |
|
| 1572 | 1572 | $text = __('Click here to cancel reply.'); |
| 1573 | 1573 | |
| 1574 | 1574 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
| 1575 | - $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
|
| 1575 | + $link = esc_html(remove_query_arg('replytocom')).'#respond'; |
|
| 1576 | 1576 | |
| 1577 | - $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; |
|
| 1577 | + $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="'.$link.'"'.$style.'>'.$text.'</a>'; |
|
| 1578 | 1578 | /** |
| 1579 | 1579 | * Filter the cancel comment reply link HTML. |
| 1580 | 1580 | * |
@@ -1584,7 +1584,7 @@ discard block |
||
| 1584 | 1584 | * @param string $link Cancel comment reply link URL. |
| 1585 | 1585 | * @param string $text Cancel comment reply link text. |
| 1586 | 1586 | */ |
| 1587 | - return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); |
|
| 1587 | + return apply_filters('cancel_comment_reply_link', $formatted_link, $link, $text); |
|
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | /** |
@@ -1594,7 +1594,7 @@ discard block |
||
| 1594 | 1594 | * |
| 1595 | 1595 | * @param string $text Optional. Text to display for cancel reply link. Default empty. |
| 1596 | 1596 | */ |
| 1597 | -function cancel_comment_reply_link( $text = '' ) { |
|
| 1597 | +function cancel_comment_reply_link($text = '') { |
|
| 1598 | 1598 | echo get_cancel_comment_reply_link($text); |
| 1599 | 1599 | } |
| 1600 | 1600 | |
@@ -1606,8 +1606,8 @@ discard block |
||
| 1606 | 1606 | * @param int $id Optional. Post ID. Default current post ID. |
| 1607 | 1607 | * @return string Hidden input HTML for replying to comments |
| 1608 | 1608 | */ |
| 1609 | -function get_comment_id_fields( $id = 0 ) { |
|
| 1610 | - if ( empty( $id ) ) |
|
| 1609 | +function get_comment_id_fields($id = 0) { |
|
| 1610 | + if (empty($id)) |
|
| 1611 | 1611 | $id = get_the_ID(); |
| 1612 | 1612 | |
| 1613 | 1613 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | * @param int $id The post ID. |
| 1624 | 1624 | * @param int $replytoid The id of the comment being replied to. |
| 1625 | 1625 | */ |
| 1626 | - return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); |
|
| 1626 | + return apply_filters('comment_id_fields', $result, $id, $replytoid); |
|
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | 1629 | /** |
@@ -1633,8 +1633,8 @@ discard block |
||
| 1633 | 1633 | * |
| 1634 | 1634 | * @param int $id Optional. Post ID. Default current post ID. |
| 1635 | 1635 | */ |
| 1636 | -function comment_id_fields( $id = 0 ) { |
|
| 1637 | - echo get_comment_id_fields( $id ); |
|
| 1636 | +function comment_id_fields($id = 0) { |
|
| 1637 | + echo get_comment_id_fields($id); |
|
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | /** |
@@ -1654,20 +1654,20 @@ discard block |
||
| 1654 | 1654 | * @param string $linktoparent Optional. Boolean to control making the author's name a link |
| 1655 | 1655 | * to their comment. Default true. |
| 1656 | 1656 | */ |
| 1657 | -function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
|
| 1657 | +function comment_form_title($noreplytext = false, $replytext = false, $linktoparent = true) { |
|
| 1658 | 1658 | global $comment; |
| 1659 | 1659 | |
| 1660 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
| 1661 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
| 1660 | + if (false === $noreplytext) $noreplytext = __('Leave a Reply'); |
|
| 1661 | + if (false === $replytext) $replytext = __('Leave a Reply to %s'); |
|
| 1662 | 1662 | |
| 1663 | 1663 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1664 | 1664 | |
| 1665 | - if ( 0 == $replytoid ) |
|
| 1665 | + if (0 == $replytoid) |
|
| 1666 | 1666 | echo $noreplytext; |
| 1667 | 1667 | else { |
| 1668 | 1668 | $comment = get_comment($replytoid); |
| 1669 | - $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author(); |
|
| 1670 | - printf( $replytext, $author ); |
|
| 1669 | + $author = ($linktoparent) ? '<a href="#comment-'.get_comment_ID().'">'.get_comment_author().'</a>' : get_comment_author(); |
|
| 1670 | + printf($replytext, $author); |
|
| 1671 | 1671 | } |
| 1672 | 1672 | } |
| 1673 | 1673 | |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | * @since 2.7.0 |
| 1697 | 1697 | * @var array |
| 1698 | 1698 | */ |
| 1699 | - public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID'); |
|
| 1699 | + public $db_fields = array('parent' => 'comment_parent', 'id' => 'comment_ID'); |
|
| 1700 | 1700 | |
| 1701 | 1701 | /** |
| 1702 | 1702 | * Start the list before the elements are added. |
@@ -1711,18 +1711,18 @@ discard block |
||
| 1711 | 1711 | * @param int $depth Depth of comment. |
| 1712 | 1712 | * @param array $args Uses 'style' argument for type of HTML list. |
| 1713 | 1713 | */ |
| 1714 | - public function start_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 1714 | + public function start_lvl(&$output, $depth = 0, $args = array()) { |
|
| 1715 | 1715 | $GLOBALS['comment_depth'] = $depth + 1; |
| 1716 | 1716 | |
| 1717 | - switch ( $args['style'] ) { |
|
| 1717 | + switch ($args['style']) { |
|
| 1718 | 1718 | case 'div': |
| 1719 | 1719 | break; |
| 1720 | 1720 | case 'ol': |
| 1721 | - $output .= '<ol class="children">' . "\n"; |
|
| 1721 | + $output .= '<ol class="children">'."\n"; |
|
| 1722 | 1722 | break; |
| 1723 | 1723 | case 'ul': |
| 1724 | 1724 | default: |
| 1725 | - $output .= '<ul class="children">' . "\n"; |
|
| 1725 | + $output .= '<ul class="children">'."\n"; |
|
| 1726 | 1726 | break; |
| 1727 | 1727 | } |
| 1728 | 1728 | } |
@@ -1740,10 +1740,10 @@ discard block |
||
| 1740 | 1740 | * @param int $depth Depth of comment. |
| 1741 | 1741 | * @param array $args Will only append content if style argument value is 'ol' or 'ul'. |
| 1742 | 1742 | */ |
| 1743 | - public function end_lvl( &$output, $depth = 0, $args = array() ) { |
|
| 1743 | + public function end_lvl(&$output, $depth = 0, $args = array()) { |
|
| 1744 | 1744 | $GLOBALS['comment_depth'] = $depth + 1; |
| 1745 | 1745 | |
| 1746 | - switch ( $args['style'] ) { |
|
| 1746 | + switch ($args['style']) { |
|
| 1747 | 1747 | case 'div': |
| 1748 | 1748 | break; |
| 1749 | 1749 | case 'ol': |
@@ -1787,22 +1787,22 @@ discard block |
||
| 1787 | 1787 | * @param array $args An array of arguments. |
| 1788 | 1788 | * @param string $output Passed by reference. Used to append additional content. |
| 1789 | 1789 | */ |
| 1790 | - public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
|
| 1791 | - if ( !$element ) |
|
| 1790 | + public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { |
|
| 1791 | + if ( ! $element) |
|
| 1792 | 1792 | return; |
| 1793 | 1793 | |
| 1794 | 1794 | $id_field = $this->db_fields['id']; |
| 1795 | 1795 | $id = $element->$id_field; |
| 1796 | 1796 | |
| 1797 | - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); |
|
| 1797 | + parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); |
|
| 1798 | 1798 | |
| 1799 | 1799 | // If we're at the max depth, and the current element still has children, loop over those and display them at this level |
| 1800 | 1800 | // This is to prevent them being orphaned to the end of the list. |
| 1801 | - if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { |
|
| 1802 | - foreach ( $children_elements[ $id ] as $child ) |
|
| 1803 | - $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); |
|
| 1801 | + if ($max_depth <= $depth + 1 && isset($children_elements[$id])) { |
|
| 1802 | + foreach ($children_elements[$id] as $child) |
|
| 1803 | + $this->display_element($child, $children_elements, $max_depth, $depth, $args, $output); |
|
| 1804 | 1804 | |
| 1805 | - unset( $children_elements[ $id ] ); |
|
| 1805 | + unset($children_elements[$id]); |
|
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | } |
@@ -1823,29 +1823,29 @@ discard block |
||
| 1823 | 1823 | * @param int $depth Depth of comment in reference to parents. |
| 1824 | 1824 | * @param array $args An array of arguments. |
| 1825 | 1825 | */ |
| 1826 | - public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { |
|
| 1826 | + public function start_el(&$output, $comment, $depth = 0, $args = array(), $id = 0) { |
|
| 1827 | 1827 | $depth++; |
| 1828 | 1828 | $GLOBALS['comment_depth'] = $depth; |
| 1829 | 1829 | $GLOBALS['comment'] = $comment; |
| 1830 | 1830 | |
| 1831 | - if ( !empty( $args['callback'] ) ) { |
|
| 1831 | + if ( ! empty($args['callback'])) { |
|
| 1832 | 1832 | ob_start(); |
| 1833 | - call_user_func( $args['callback'], $comment, $args, $depth ); |
|
| 1833 | + call_user_func($args['callback'], $comment, $args, $depth); |
|
| 1834 | 1834 | $output .= ob_get_clean(); |
| 1835 | 1835 | return; |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | - if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) { |
|
| 1838 | + if (('pingback' == $comment->comment_type || 'trackback' == $comment->comment_type) && $args['short_ping']) { |
|
| 1839 | 1839 | ob_start(); |
| 1840 | - $this->ping( $comment, $depth, $args ); |
|
| 1840 | + $this->ping($comment, $depth, $args); |
|
| 1841 | 1841 | $output .= ob_get_clean(); |
| 1842 | - } elseif ( 'html5' === $args['format'] ) { |
|
| 1842 | + } elseif ('html5' === $args['format']) { |
|
| 1843 | 1843 | ob_start(); |
| 1844 | - $this->html5_comment( $comment, $depth, $args ); |
|
| 1844 | + $this->html5_comment($comment, $depth, $args); |
|
| 1845 | 1845 | $output .= ob_get_clean(); |
| 1846 | 1846 | } else { |
| 1847 | 1847 | ob_start(); |
| 1848 | - $this->comment( $comment, $depth, $args ); |
|
| 1848 | + $this->comment($comment, $depth, $args); |
|
| 1849 | 1849 | $output .= ob_get_clean(); |
| 1850 | 1850 | } |
| 1851 | 1851 | } |
@@ -1863,14 +1863,14 @@ discard block |
||
| 1863 | 1863 | * @param int $depth Depth of comment. |
| 1864 | 1864 | * @param array $args An array of arguments. |
| 1865 | 1865 | */ |
| 1866 | - public function end_el( &$output, $comment, $depth = 0, $args = array() ) { |
|
| 1867 | - if ( !empty( $args['end-callback'] ) ) { |
|
| 1866 | + public function end_el(&$output, $comment, $depth = 0, $args = array()) { |
|
| 1867 | + if ( ! empty($args['end-callback'])) { |
|
| 1868 | 1868 | ob_start(); |
| 1869 | - call_user_func( $args['end-callback'], $comment, $args, $depth ); |
|
| 1869 | + call_user_func($args['end-callback'], $comment, $args, $depth); |
|
| 1870 | 1870 | $output .= ob_get_clean(); |
| 1871 | 1871 | return; |
| 1872 | 1872 | } |
| 1873 | - if ( 'div' == $args['style'] ) |
|
| 1873 | + if ('div' == $args['style']) |
|
| 1874 | 1874 | $output .= "</div><!-- #comment-## -->\n"; |
| 1875 | 1875 | else |
| 1876 | 1876 | $output .= "</li><!-- #comment-## -->\n"; |
@@ -1888,12 +1888,12 @@ discard block |
||
| 1888 | 1888 | * @param int $depth Depth of comment. |
| 1889 | 1889 | * @param array $args An array of arguments. |
| 1890 | 1890 | */ |
| 1891 | - protected function ping( $comment, $depth, $args ) { |
|
| 1892 | - $tag = ( 'div' == $args['style'] ) ? 'div' : 'li'; |
|
| 1891 | + protected function ping($comment, $depth, $args) { |
|
| 1892 | + $tag = ('div' == $args['style']) ? 'div' : 'li'; |
|
| 1893 | 1893 | ?> |
| 1894 | 1894 | <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>> |
| 1895 | 1895 | <div class="comment-body"> |
| 1896 | - <?php _e( 'Pingback:' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> |
|
| 1896 | + <?php _e('Pingback:'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('Edit'), '<span class="edit-link">', '</span>'); ?> |
|
| 1897 | 1897 | </div> |
| 1898 | 1898 | <?php |
| 1899 | 1899 | } |
@@ -1910,8 +1910,8 @@ discard block |
||
| 1910 | 1910 | * @param int $depth Depth of comment. |
| 1911 | 1911 | * @param array $args An array of arguments. |
| 1912 | 1912 | */ |
| 1913 | - protected function comment( $comment, $depth, $args ) { |
|
| 1914 | - if ( 'div' == $args['style'] ) { |
|
| 1913 | + protected function comment($comment, $depth, $args) { |
|
| 1914 | + if ('div' == $args['style']) { |
|
| 1915 | 1915 | $tag = 'div'; |
| 1916 | 1916 | $add_below = 'comment'; |
| 1917 | 1917 | } else { |
@@ -1919,39 +1919,39 @@ discard block |
||
| 1919 | 1919 | $add_below = 'div-comment'; |
| 1920 | 1920 | } |
| 1921 | 1921 | ?> |
| 1922 | - <<?php echo $tag; ?> <?php comment_class( $this->has_children ? 'parent' : '' ); ?> id="comment-<?php comment_ID(); ?>"> |
|
| 1923 | - <?php if ( 'div' != $args['style'] ) : ?> |
|
| 1922 | + <<?php echo $tag; ?> <?php comment_class($this->has_children ? 'parent' : ''); ?> id="comment-<?php comment_ID(); ?>"> |
|
| 1923 | + <?php if ('div' != $args['style']) : ?> |
|
| 1924 | 1924 | <div id="div-comment-<?php comment_ID(); ?>" class="comment-body"> |
| 1925 | 1925 | <?php endif; ?> |
| 1926 | 1926 | <div class="comment-author vcard"> |
| 1927 | - <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
|
| 1928 | - <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?> |
|
| 1927 | + <?php if (0 != $args['avatar_size']) echo get_avatar($comment, $args['avatar_size']); ?> |
|
| 1928 | + <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()); ?> |
|
| 1929 | 1929 | </div> |
| 1930 | - <?php if ( '0' == $comment->comment_approved ) : ?> |
|
| 1931 | - <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ) ?></em> |
|
| 1930 | + <?php if ('0' == $comment->comment_approved) : ?> |
|
| 1931 | + <em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em> |
|
| 1932 | 1932 | <br /> |
| 1933 | 1933 | <?php endif; ?> |
| 1934 | 1934 | |
| 1935 | - <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>"> |
|
| 1935 | + <div class="comment-meta commentmetadata"><a href="<?php echo esc_url(get_comment_link($comment->comment_ID, $args)); ?>"> |
|
| 1936 | 1936 | <?php |
| 1937 | 1937 | /* translators: 1: date, 2: time */ |
| 1938 | - printf( __( '%1$s at %2$s' ), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' ); |
|
| 1938 | + printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()); ?></a><?php edit_comment_link(__('(Edit)'), ' ', ''); |
|
| 1939 | 1939 | ?> |
| 1940 | 1940 | </div> |
| 1941 | 1941 | |
| 1942 | - <?php comment_text( get_comment_id(), array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> |
|
| 1942 | + <?php comment_text(get_comment_id(), array_merge($args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))); ?> |
|
| 1943 | 1943 | |
| 1944 | 1944 | <?php |
| 1945 | - comment_reply_link( array_merge( $args, array( |
|
| 1945 | + comment_reply_link(array_merge($args, array( |
|
| 1946 | 1946 | 'add_below' => $add_below, |
| 1947 | 1947 | 'depth' => $depth, |
| 1948 | 1948 | 'max_depth' => $args['max_depth'], |
| 1949 | 1949 | 'before' => '<div class="reply">', |
| 1950 | 1950 | 'after' => '</div>' |
| 1951 | - ) ) ); |
|
| 1951 | + ))); |
|
| 1952 | 1952 | ?> |
| 1953 | 1953 | |
| 1954 | - <?php if ( 'div' != $args['style'] ) : ?> |
|
| 1954 | + <?php if ('div' != $args['style']) : ?> |
|
| 1955 | 1955 | </div> |
| 1956 | 1956 | <?php endif; ?> |
| 1957 | 1957 | <?php |
@@ -1969,28 +1969,28 @@ discard block |
||
| 1969 | 1969 | * @param int $depth Depth of comment. |
| 1970 | 1970 | * @param array $args An array of arguments. |
| 1971 | 1971 | */ |
| 1972 | - protected function html5_comment( $comment, $depth, $args ) { |
|
| 1973 | - $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; |
|
| 1972 | + protected function html5_comment($comment, $depth, $args) { |
|
| 1973 | + $tag = ('div' === $args['style']) ? 'div' : 'li'; |
|
| 1974 | 1974 | ?> |
| 1975 | - <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '' ); ?>> |
|
| 1975 | + <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class($this->has_children ? 'parent' : ''); ?>> |
|
| 1976 | 1976 | <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> |
| 1977 | 1977 | <footer class="comment-meta"> |
| 1978 | 1978 | <div class="comment-author vcard"> |
| 1979 | - <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
|
| 1980 | - <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?> |
|
| 1979 | + <?php if (0 != $args['avatar_size']) echo get_avatar($comment, $args['avatar_size']); ?> |
|
| 1980 | + <?php printf(__('%s <span class="says">says:</span>'), sprintf('<b class="fn">%s</b>', get_comment_author_link())); ?> |
|
| 1981 | 1981 | </div><!-- .comment-author --> |
| 1982 | 1982 | |
| 1983 | 1983 | <div class="comment-metadata"> |
| 1984 | - <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>"> |
|
| 1985 | - <time datetime="<?php comment_time( 'c' ); ?>"> |
|
| 1986 | - <?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?> |
|
| 1984 | + <a href="<?php echo esc_url(get_comment_link($comment->comment_ID, $args)); ?>"> |
|
| 1985 | + <time datetime="<?php comment_time('c'); ?>"> |
|
| 1986 | + <?php printf(_x('%1$s at %2$s', '1: date, 2: time'), get_comment_date(), get_comment_time()); ?> |
|
| 1987 | 1987 | </time> |
| 1988 | 1988 | </a> |
| 1989 | - <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> |
|
| 1989 | + <?php edit_comment_link(__('Edit'), '<span class="edit-link">', '</span>'); ?> |
|
| 1990 | 1990 | </div><!-- .comment-metadata --> |
| 1991 | 1991 | |
| 1992 | - <?php if ( '0' == $comment->comment_approved ) : ?> |
|
| 1993 | - <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p> |
|
| 1992 | + <?php if ('0' == $comment->comment_approved) : ?> |
|
| 1993 | + <p class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.'); ?></p> |
|
| 1994 | 1994 | <?php endif; ?> |
| 1995 | 1995 | </footer><!-- .comment-meta --> |
| 1996 | 1996 | |
@@ -1999,13 +1999,13 @@ discard block |
||
| 1999 | 1999 | </div><!-- .comment-content --> |
| 2000 | 2000 | |
| 2001 | 2001 | <?php |
| 2002 | - comment_reply_link( array_merge( $args, array( |
|
| 2002 | + comment_reply_link(array_merge($args, array( |
|
| 2003 | 2003 | 'add_below' => 'div-comment', |
| 2004 | 2004 | 'depth' => $depth, |
| 2005 | 2005 | 'max_depth' => $args['max_depth'], |
| 2006 | 2006 | 'before' => '<div class="reply">', |
| 2007 | 2007 | 'after' => '</div>' |
| 2008 | - ) ) ); |
|
| 2008 | + ))); |
|
| 2009 | 2009 | ?> |
| 2010 | 2010 | </article><!-- .comment-body --> |
| 2011 | 2011 | <?php |
@@ -2050,7 +2050,7 @@ discard block |
||
| 2050 | 2050 | * } |
| 2051 | 2051 | * @param array $comments Optional. Array of comment objects. |
| 2052 | 2052 | */ |
| 2053 | -function wp_list_comments( $args = array(), $comments = null ) { |
|
| 2053 | +function wp_list_comments($args = array(), $comments = null) { |
|
| 2054 | 2054 | global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; |
| 2055 | 2055 | |
| 2056 | 2056 | $in_comment_loop = true; |
@@ -2070,12 +2070,12 @@ discard block |
||
| 2070 | 2070 | 'avatar_size' => 32, |
| 2071 | 2071 | 'reverse_top_level' => null, |
| 2072 | 2072 | 'reverse_children' => '', |
| 2073 | - 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml', |
|
| 2073 | + 'format' => current_theme_supports('html5', 'comment-list') ? 'html5' : 'xhtml', |
|
| 2074 | 2074 | 'short_ping' => false, |
| 2075 | 2075 | 'echo' => true, |
| 2076 | 2076 | ); |
| 2077 | 2077 | |
| 2078 | - $r = wp_parse_args( $args, $defaults ); |
|
| 2078 | + $r = wp_parse_args($args, $defaults); |
|
| 2079 | 2079 | |
| 2080 | 2080 | /** |
| 2081 | 2081 | * Filter the arguments used in retrieving the comment list. |
@@ -2086,28 +2086,28 @@ discard block |
||
| 2086 | 2086 | * |
| 2087 | 2087 | * @param array $r An array of arguments for displaying comments. |
| 2088 | 2088 | */ |
| 2089 | - $r = apply_filters( 'wp_list_comments_args', $r ); |
|
| 2089 | + $r = apply_filters('wp_list_comments_args', $r); |
|
| 2090 | 2090 | |
| 2091 | 2091 | // Figure out what comments we'll be looping through ($_comments) |
| 2092 | - if ( null !== $comments ) { |
|
| 2092 | + if (null !== $comments) { |
|
| 2093 | 2093 | $comments = (array) $comments; |
| 2094 | - if ( empty($comments) ) |
|
| 2094 | + if (empty($comments)) |
|
| 2095 | 2095 | return; |
| 2096 | - if ( 'all' != $r['type'] ) { |
|
| 2096 | + if ('all' != $r['type']) { |
|
| 2097 | 2097 | $comments_by_type = separate_comments($comments); |
| 2098 | - if ( empty($comments_by_type[$r['type']]) ) |
|
| 2098 | + if (empty($comments_by_type[$r['type']])) |
|
| 2099 | 2099 | return; |
| 2100 | 2100 | $_comments = $comments_by_type[$r['type']]; |
| 2101 | 2101 | } else { |
| 2102 | 2102 | $_comments = $comments; |
| 2103 | 2103 | } |
| 2104 | 2104 | } else { |
| 2105 | - if ( empty($wp_query->comments) ) |
|
| 2105 | + if (empty($wp_query->comments)) |
|
| 2106 | 2106 | return; |
| 2107 | - if ( 'all' != $r['type'] ) { |
|
| 2108 | - if ( empty($wp_query->comments_by_type) ) |
|
| 2107 | + if ('all' != $r['type']) { |
|
| 2108 | + if (empty($wp_query->comments_by_type)) |
|
| 2109 | 2109 | $wp_query->comments_by_type = separate_comments($wp_query->comments); |
| 2110 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
| 2110 | + if (empty($wp_query->comments_by_type[$r['type']])) |
|
| 2111 | 2111 | return; |
| 2112 | 2112 | $_comments = $wp_query->comments_by_type[$r['type']]; |
| 2113 | 2113 | } else { |
@@ -2115,50 +2115,50 @@ discard block |
||
| 2115 | 2115 | } |
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | - if ( '' === $r['per_page'] && get_option('page_comments') ) |
|
| 2118 | + if ('' === $r['per_page'] && get_option('page_comments')) |
|
| 2119 | 2119 | $r['per_page'] = get_query_var('comments_per_page'); |
| 2120 | 2120 | |
| 2121 | - if ( empty($r['per_page']) ) { |
|
| 2121 | + if (empty($r['per_page'])) { |
|
| 2122 | 2122 | $r['per_page'] = 0; |
| 2123 | 2123 | $r['page'] = 0; |
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | - if ( '' === $r['max_depth'] ) { |
|
| 2127 | - if ( get_option('thread_comments') ) |
|
| 2126 | + if ('' === $r['max_depth']) { |
|
| 2127 | + if (get_option('thread_comments')) |
|
| 2128 | 2128 | $r['max_depth'] = get_option('thread_comments_depth'); |
| 2129 | 2129 | else |
| 2130 | 2130 | $r['max_depth'] = -1; |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | - if ( '' === $r['page'] ) { |
|
| 2134 | - if ( empty($overridden_cpage) ) { |
|
| 2133 | + if ('' === $r['page']) { |
|
| 2134 | + if (empty($overridden_cpage)) { |
|
| 2135 | 2135 | $r['page'] = get_query_var('cpage'); |
| 2136 | 2136 | } else { |
| 2137 | 2137 | $threaded = ( -1 != $r['max_depth'] ); |
| 2138 | - $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
| 2139 | - set_query_var( 'cpage', $r['page'] ); |
|
| 2138 | + $r['page'] = ('newest' == get_option('default_comments_page')) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
|
| 2139 | + set_query_var('cpage', $r['page']); |
|
| 2140 | 2140 | } |
| 2141 | 2141 | } |
| 2142 | 2142 | // Validation check |
| 2143 | 2143 | $r['page'] = intval($r['page']); |
| 2144 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
| 2144 | + if (0 == $r['page'] && 0 != $r['per_page']) |
|
| 2145 | 2145 | $r['page'] = 1; |
| 2146 | 2146 | |
| 2147 | - if ( null === $r['reverse_top_level'] ) |
|
| 2148 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2147 | + if (null === $r['reverse_top_level']) |
|
| 2148 | + $r['reverse_top_level'] = ('desc' == get_option('comment_order')); |
|
| 2149 | 2149 | |
| 2150 | - if ( empty( $r['walker'] ) ) { |
|
| 2150 | + if (empty($r['walker'])) { |
|
| 2151 | 2151 | $walker = new Walker_Comment; |
| 2152 | 2152 | } else { |
| 2153 | 2153 | $walker = $r['walker']; |
| 2154 | 2154 | } |
| 2155 | 2155 | |
| 2156 | - $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r ); |
|
| 2156 | + $output = $walker->paged_walk($_comments, $r['max_depth'], $r['page'], $r['per_page'], $r); |
|
| 2157 | 2157 | $wp_query->max_num_comment_pages = $walker->max_pages; |
| 2158 | 2158 | |
| 2159 | 2159 | $in_comment_loop = false; |
| 2160 | 2160 | |
| 2161 | - if ( $r['echo'] ) { |
|
| 2161 | + if ($r['echo']) { |
|
| 2162 | 2162 | echo $output; |
| 2163 | 2163 | } else { |
| 2164 | 2164 | return $output; |
@@ -2213,32 +2213,32 @@ discard block |
||
| 2213 | 2213 | * } |
| 2214 | 2214 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
| 2215 | 2215 | */ |
| 2216 | -function comment_form( $args = array(), $post_id = null ) { |
|
| 2217 | - if ( null === $post_id ) |
|
| 2216 | +function comment_form($args = array(), $post_id = null) { |
|
| 2217 | + if (null === $post_id) |
|
| 2218 | 2218 | $post_id = get_the_ID(); |
| 2219 | 2219 | |
| 2220 | 2220 | $commenter = wp_get_current_commenter(); |
| 2221 | 2221 | $user = wp_get_current_user(); |
| 2222 | 2222 | $user_identity = $user->exists() ? $user->display_name : ''; |
| 2223 | 2223 | |
| 2224 | - $args = wp_parse_args( $args ); |
|
| 2225 | - if ( ! isset( $args['format'] ) ) |
|
| 2226 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2224 | + $args = wp_parse_args($args); |
|
| 2225 | + if ( ! isset($args['format'])) |
|
| 2226 | + $args['format'] = current_theme_supports('html5', 'comment-form') ? 'html5' : 'xhtml'; |
|
| 2227 | 2227 | |
| 2228 | - $req = get_option( 'require_name_email' ); |
|
| 2229 | - $aria_req = ( $req ? " aria-required='true'" : '' ); |
|
| 2230 | - $html_req = ( $req ? " required='required'" : '' ); |
|
| 2228 | + $req = get_option('require_name_email'); |
|
| 2229 | + $aria_req = ($req ? " aria-required='true'" : ''); |
|
| 2230 | + $html_req = ($req ? " required='required'" : ''); |
|
| 2231 | 2231 | $html5 = 'html5' === $args['format']; |
| 2232 | - $fields = array( |
|
| 2233 | - 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
| 2234 | - '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>', |
|
| 2235 | - 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
|
| 2236 | - '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>', |
|
| 2237 | - 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
|
| 2238 | - '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', |
|
| 2232 | + $fields = array( |
|
| 2233 | + 'author' => '<p class="comment-form-author">'.'<label for="author">'.__('Name').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
| 2234 | + '<input id="author" name="author" type="text" value="'.esc_attr($commenter['comment_author']).'" size="30"'.$aria_req.$html_req.' /></p>', |
|
| 2235 | + 'email' => '<p class="comment-form-email"><label for="email">'.__('Email').($req ? ' <span class="required">*</span>' : '').'</label> '. |
|
| 2236 | + '<input id="email" name="email" '.($html5 ? 'type="email"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_email']).'" size="30" aria-describedby="email-notes"'.$aria_req.$html_req.' /></p>', |
|
| 2237 | + 'url' => '<p class="comment-form-url"><label for="url">'.__('Website').'</label> '. |
|
| 2238 | + '<input id="url" name="url" '.($html5 ? 'type="url"' : 'type="text"').' value="'.esc_attr($commenter['comment_author_url']).'" size="30" /></p>', |
|
| 2239 | 2239 | ); |
| 2240 | 2240 | |
| 2241 | - $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); |
|
| 2241 | + $required_text = sprintf(' '.__('Required fields are marked %s'), '<span class="required">*</span>'); |
|
| 2242 | 2242 | |
| 2243 | 2243 | /** |
| 2244 | 2244 | * Filter the default comment form fields. |
@@ -2247,24 +2247,24 @@ discard block |
||
| 2247 | 2247 | * |
| 2248 | 2248 | * @param array $fields The default comment fields. |
| 2249 | 2249 | */ |
| 2250 | - $fields = apply_filters( 'comment_form_default_fields', $fields ); |
|
| 2250 | + $fields = apply_filters('comment_form_default_fields', $fields); |
|
| 2251 | 2251 | $defaults = array( |
| 2252 | 2252 | 'fields' => $fields, |
| 2253 | - 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required="required"></textarea></p>', |
|
| 2253 | + 'comment_field' => '<p class="comment-form-comment"><label for="comment">'._x('Comment', 'noun').'</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required="required"></textarea></p>', |
|
| 2254 | 2254 | /** This filter is documented in wp-includes/link-template.php */ |
| 2255 | - 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
|
| 2255 | + 'must_log_in' => '<p class="must-log-in">'.sprintf(__('You must be <a href="%s">logged in</a> to post a comment.'), wp_login_url(apply_filters('the_permalink', get_permalink($post_id)))).'</p>', |
|
| 2256 | 2256 | /** This filter is documented in wp-includes/link-template.php */ |
| 2257 | - 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', |
|
| 2258 | - 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
|
| 2257 | + 'logged_in_as' => '<p class="logged-in-as">'.sprintf(__('Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>'), get_edit_user_link(), $user_identity, wp_logout_url(apply_filters('the_permalink', get_permalink($post_id)))).'</p>', |
|
| 2258 | + 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">'.__('Your email address will not be published.').'</span>'.($req ? $required_text : '').'</p>', |
|
| 2259 | 2259 | 'comment_notes_after' => '', |
| 2260 | 2260 | 'id_form' => 'commentform', |
| 2261 | 2261 | 'id_submit' => 'submit', |
| 2262 | 2262 | 'class_submit' => 'submit', |
| 2263 | 2263 | 'name_submit' => 'submit', |
| 2264 | - 'title_reply' => __( 'Leave a Reply' ), |
|
| 2265 | - 'title_reply_to' => __( 'Leave a Reply to %s' ), |
|
| 2266 | - 'cancel_reply_link' => __( 'Cancel reply' ), |
|
| 2267 | - 'label_submit' => __( 'Post Comment' ), |
|
| 2264 | + 'title_reply' => __('Leave a Reply'), |
|
| 2265 | + 'title_reply_to' => __('Leave a Reply to %s'), |
|
| 2266 | + 'cancel_reply_link' => __('Cancel reply'), |
|
| 2267 | + 'label_submit' => __('Post Comment'), |
|
| 2268 | 2268 | 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />', |
| 2269 | 2269 | 'submit_field' => '<p class="form-submit">%1$s %2$s</p>', |
| 2270 | 2270 | 'format' => 'xhtml', |
@@ -2279,23 +2279,23 @@ discard block |
||
| 2279 | 2279 | * |
| 2280 | 2280 | * @param array $defaults The default comment form arguments. |
| 2281 | 2281 | */ |
| 2282 | - $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); |
|
| 2282 | + $args = wp_parse_args($args, apply_filters('comment_form_defaults', $defaults)); |
|
| 2283 | 2283 | |
| 2284 | 2284 | // Ensure that the filtered args contain all required default values. |
| 2285 | - $args = array_merge( $defaults, $args ); |
|
| 2285 | + $args = array_merge($defaults, $args); |
|
| 2286 | 2286 | |
| 2287 | - if ( comments_open( $post_id ) ) : ?> |
|
| 2287 | + if (comments_open($post_id)) : ?> |
|
| 2288 | 2288 | <?php |
| 2289 | 2289 | /** |
| 2290 | 2290 | * Fires before the comment form. |
| 2291 | 2291 | * |
| 2292 | 2292 | * @since 3.0.0 |
| 2293 | 2293 | */ |
| 2294 | - do_action( 'comment_form_before' ); |
|
| 2294 | + do_action('comment_form_before'); |
|
| 2295 | 2295 | ?> |
| 2296 | 2296 | <div id="respond" class="comment-respond"> |
| 2297 | - <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3> |
|
| 2298 | - <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> |
|
| 2297 | + <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title($args['title_reply'], $args['title_reply_to']); ?> <small><?php cancel_comment_reply_link($args['cancel_reply_link']); ?></small></h3> |
|
| 2298 | + <?php if (get_option('comment_registration') && ! is_user_logged_in()) : ?> |
|
| 2299 | 2299 | <?php echo $args['must_log_in']; ?> |
| 2300 | 2300 | <?php |
| 2301 | 2301 | /** |
@@ -2303,19 +2303,19 @@ discard block |
||
| 2303 | 2303 | * |
| 2304 | 2304 | * @since 3.0.0 |
| 2305 | 2305 | */ |
| 2306 | - do_action( 'comment_form_must_log_in_after' ); |
|
| 2306 | + do_action('comment_form_must_log_in_after'); |
|
| 2307 | 2307 | ?> |
| 2308 | 2308 | <?php else : ?> |
| 2309 | - <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2309 | + <form action="<?php echo site_url('/wp-comments-post.php'); ?>" method="post" id="<?php echo esc_attr($args['id_form']); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2310 | 2310 | <?php |
| 2311 | 2311 | /** |
| 2312 | 2312 | * Fires at the top of the comment form, inside the form tag. |
| 2313 | 2313 | * |
| 2314 | 2314 | * @since 3.0.0 |
| 2315 | 2315 | */ |
| 2316 | - do_action( 'comment_form_top' ); |
|
| 2316 | + do_action('comment_form_top'); |
|
| 2317 | 2317 | ?> |
| 2318 | - <?php if ( is_user_logged_in() ) : ?> |
|
| 2318 | + <?php if (is_user_logged_in()) : ?> |
|
| 2319 | 2319 | <?php |
| 2320 | 2320 | /** |
| 2321 | 2321 | * Filter the 'logged in' message for the comment form for display. |
@@ -2328,7 +2328,7 @@ discard block |
||
| 2328 | 2328 | * @param string $user_identity If the commenter is a registered user, |
| 2329 | 2329 | * the display name, blank otherwise. |
| 2330 | 2330 | */ |
| 2331 | - echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); |
|
| 2331 | + echo apply_filters('comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity); |
|
| 2332 | 2332 | ?> |
| 2333 | 2333 | <?php |
| 2334 | 2334 | /** |
@@ -2341,7 +2341,7 @@ discard block |
||
| 2341 | 2341 | * @param string $user_identity If the commenter is a registered user, |
| 2342 | 2342 | * the display name, blank otherwise. |
| 2343 | 2343 | */ |
| 2344 | - do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
|
| 2344 | + do_action('comment_form_logged_in_after', $commenter, $user_identity); |
|
| 2345 | 2345 | ?> |
| 2346 | 2346 | <?php else : ?> |
| 2347 | 2347 | <?php echo $args['comment_notes_before']; ?> |
@@ -2351,8 +2351,8 @@ discard block |
||
| 2351 | 2351 | * |
| 2352 | 2352 | * @since 3.0.0 |
| 2353 | 2353 | */ |
| 2354 | - do_action( 'comment_form_before_fields' ); |
|
| 2355 | - foreach ( (array) $args['fields'] as $name => $field ) { |
|
| 2354 | + do_action('comment_form_before_fields'); |
|
| 2355 | + foreach ((array) $args['fields'] as $name => $field) { |
|
| 2356 | 2356 | /** |
| 2357 | 2357 | * Filter a comment form field for display. |
| 2358 | 2358 | * |
@@ -2363,14 +2363,14 @@ discard block |
||
| 2363 | 2363 | * |
| 2364 | 2364 | * @param string $field The HTML-formatted output of the comment form field. |
| 2365 | 2365 | */ |
| 2366 | - echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; |
|
| 2366 | + echo apply_filters("comment_form_field_{$name}", $field)."\n"; |
|
| 2367 | 2367 | } |
| 2368 | 2368 | /** |
| 2369 | 2369 | * Fires after the comment fields in the comment form. |
| 2370 | 2370 | * |
| 2371 | 2371 | * @since 3.0.0 |
| 2372 | 2372 | */ |
| 2373 | - do_action( 'comment_form_after_fields' ); |
|
| 2373 | + do_action('comment_form_after_fields'); |
|
| 2374 | 2374 | ?> |
| 2375 | 2375 | <?php endif; ?> |
| 2376 | 2376 | <?php |
@@ -2381,17 +2381,17 @@ discard block |
||
| 2381 | 2381 | * |
| 2382 | 2382 | * @param string $args_comment_field The content of the comment textarea field. |
| 2383 | 2383 | */ |
| 2384 | - echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); |
|
| 2384 | + echo apply_filters('comment_form_field_comment', $args['comment_field']); |
|
| 2385 | 2385 | ?> |
| 2386 | 2386 | <?php echo $args['comment_notes_after']; ?> |
| 2387 | 2387 | |
| 2388 | 2388 | <?php |
| 2389 | 2389 | $submit_button = sprintf( |
| 2390 | 2390 | $args['submit_button'], |
| 2391 | - esc_attr( $args['name_submit'] ), |
|
| 2392 | - esc_attr( $args['id_submit'] ), |
|
| 2393 | - esc_attr( $args['class_submit'] ), |
|
| 2394 | - esc_attr( $args['label_submit'] ) |
|
| 2391 | + esc_attr($args['name_submit']), |
|
| 2392 | + esc_attr($args['id_submit']), |
|
| 2393 | + esc_attr($args['class_submit']), |
|
| 2394 | + esc_attr($args['label_submit']) |
|
| 2395 | 2395 | ); |
| 2396 | 2396 | |
| 2397 | 2397 | /** |
@@ -2402,12 +2402,12 @@ discard block |
||
| 2402 | 2402 | * @param string $submit_button HTML markup for the submit button. |
| 2403 | 2403 | * @param array $args Arguments passed to `comment_form()`. |
| 2404 | 2404 | */ |
| 2405 | - $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args ); |
|
| 2405 | + $submit_button = apply_filters('comment_form_submit_button', $submit_button, $args); |
|
| 2406 | 2406 | |
| 2407 | 2407 | $submit_field = sprintf( |
| 2408 | 2408 | $args['submit_field'], |
| 2409 | 2409 | $submit_button, |
| 2410 | - get_comment_id_fields( $post_id ) |
|
| 2410 | + get_comment_id_fields($post_id) |
|
| 2411 | 2411 | ); |
| 2412 | 2412 | |
| 2413 | 2413 | /** |
@@ -2421,7 +2421,7 @@ discard block |
||
| 2421 | 2421 | * @param string $submit_field HTML markup for the submit field. |
| 2422 | 2422 | * @param array $args Arguments passed to comment_form(). |
| 2423 | 2423 | */ |
| 2424 | - echo apply_filters( 'comment_form_submit_field', $submit_field, $args ); |
|
| 2424 | + echo apply_filters('comment_form_submit_field', $submit_field, $args); |
|
| 2425 | 2425 | |
| 2426 | 2426 | /** |
| 2427 | 2427 | * Fires at the bottom of the comment form, inside the closing </form> tag. |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | * |
| 2431 | 2431 | * @param int $post_id The post ID. |
| 2432 | 2432 | */ |
| 2433 | - do_action( 'comment_form', $post_id ); |
|
| 2433 | + do_action('comment_form', $post_id); |
|
| 2434 | 2434 | ?> |
| 2435 | 2435 | </form> |
| 2436 | 2436 | <?php endif; ?> |
@@ -2441,13 +2441,13 @@ discard block |
||
| 2441 | 2441 | * |
| 2442 | 2442 | * @since 3.0.0 |
| 2443 | 2443 | */ |
| 2444 | - do_action( 'comment_form_after' ); |
|
| 2444 | + do_action('comment_form_after'); |
|
| 2445 | 2445 | else : |
| 2446 | 2446 | /** |
| 2447 | 2447 | * Fires after the comment form if comments are closed. |
| 2448 | 2448 | * |
| 2449 | 2449 | * @since 3.0.0 |
| 2450 | 2450 | */ |
| 2451 | - do_action( 'comment_form_comments_closed' ); |
|
| 2451 | + do_action('comment_form_comments_closed'); |
|
| 2452 | 2452 | endif; |
| 2453 | 2453 | } |
@@ -23,10 +23,11 @@ discard block |
||
| 23 | 23 | $comment = get_comment( $comment_ID ); |
| 24 | 24 | |
| 25 | 25 | if ( empty( $comment->comment_author ) ) { |
| 26 | - if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
|
| 27 | - $author = $user->display_name; |
|
| 28 | - else |
|
| 29 | - $author = __('Anonymous'); |
|
| 26 | + if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { |
|
| 27 | + $author = $user->display_name; |
|
| 28 | + } else { |
|
| 29 | + $author = __('Anonymous'); |
|
| 30 | + } |
|
| 30 | 31 | } else { |
| 31 | 32 | $author = $comment->comment_author; |
| 32 | 33 | } |
@@ -135,9 +136,10 @@ discard block |
||
| 135 | 136 | * @param string $after Optional. Text or HTML to display after the email link. Default empty. |
| 136 | 137 | */ |
| 137 | 138 | function comment_author_email_link( $linktext = '', $before = '', $after = '' ) { |
| 138 | - if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) |
|
| 139 | - echo $link; |
|
| 140 | -} |
|
| 139 | + if ( $link = get_comment_author_email_link( $linktext, $before, $after ) ) { |
|
| 140 | + echo $link; |
|
| 141 | + } |
|
| 142 | + } |
|
| 141 | 143 | |
| 142 | 144 | /** |
| 143 | 145 | * Return the html email link to the author of the current comment. |
@@ -201,10 +203,11 @@ discard block |
||
| 201 | 203 | $url = get_comment_author_url( $comment_ID ); |
| 202 | 204 | $author = get_comment_author( $comment_ID ); |
| 203 | 205 | |
| 204 | - if ( empty( $url ) || 'http://' == $url ) |
|
| 205 | - $return = $author; |
|
| 206 | - else |
|
| 207 | - $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
| 206 | + if ( empty( $url ) || 'http://' == $url ) { |
|
| 207 | + $return = $author; |
|
| 208 | + } else { |
|
| 209 | + $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
| 210 | + } |
|
| 208 | 211 | |
| 209 | 212 | /** |
| 210 | 213 | * Filter the comment author's link for display. |
@@ -393,11 +396,12 @@ discard block |
||
| 393 | 396 | function comment_class( $class = '', $comment_id = null, $post_id = null, $echo = true ) { |
| 394 | 397 | // Separates classes with a single space, collates classes for comment DIV |
| 395 | 398 | $class = 'class="' . join( ' ', get_comment_class( $class, $comment_id, $post_id ) ) . '"'; |
| 396 | - if ( $echo) |
|
| 397 | - echo $class; |
|
| 398 | - else |
|
| 399 | - return $class; |
|
| 400 | -} |
|
| 399 | + if ( $echo) { |
|
| 400 | + echo $class; |
|
| 401 | + } else { |
|
| 402 | + return $class; |
|
| 403 | + } |
|
| 404 | + } |
|
| 401 | 405 | |
| 402 | 406 | /** |
| 403 | 407 | * Returns the classes for the comment div as an array. |
@@ -435,12 +439,15 @@ discard block |
||
| 435 | 439 | } |
| 436 | 440 | } |
| 437 | 441 | |
| 438 | - if ( empty($comment_alt) ) |
|
| 439 | - $comment_alt = 0; |
|
| 440 | - if ( empty($comment_depth) ) |
|
| 441 | - $comment_depth = 1; |
|
| 442 | - if ( empty($comment_thread_alt) ) |
|
| 443 | - $comment_thread_alt = 0; |
|
| 442 | + if ( empty($comment_alt) ) { |
|
| 443 | + $comment_alt = 0; |
|
| 444 | + } |
|
| 445 | + if ( empty($comment_depth) ) { |
|
| 446 | + $comment_depth = 1; |
|
| 447 | + } |
|
| 448 | + if ( empty($comment_thread_alt) ) { |
|
| 449 | + $comment_thread_alt = 0; |
|
| 450 | + } |
|
| 444 | 451 | |
| 445 | 452 | if ( $comment_alt % 2 ) { |
| 446 | 453 | $classes[] = 'odd'; |
@@ -465,8 +472,9 @@ discard block |
||
| 465 | 472 | $classes[] = "depth-$comment_depth"; |
| 466 | 473 | |
| 467 | 474 | if ( !empty($class) ) { |
| 468 | - if ( !is_array( $class ) ) |
|
| 469 | - $class = preg_split('#\s+#', $class); |
|
| 475 | + if ( !is_array( $class ) ) { |
|
| 476 | + $class = preg_split('#\s+#', $class); |
|
| 477 | + } |
|
| 470 | 478 | $classes = array_merge($classes, $class); |
| 471 | 479 | } |
| 472 | 480 | |
@@ -497,10 +505,11 @@ discard block |
||
| 497 | 505 | */ |
| 498 | 506 | function get_comment_date( $d = '', $comment_ID = 0 ) { |
| 499 | 507 | $comment = get_comment( $comment_ID ); |
| 500 | - if ( '' == $d ) |
|
| 501 | - $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
| 502 | - else |
|
| 503 | - $date = mysql2date($d, $comment->comment_date); |
|
| 508 | + if ( '' == $d ) { |
|
| 509 | + $date = mysql2date(get_option('date_format'), $comment->comment_date); |
|
| 510 | + } else { |
|
| 511 | + $date = mysql2date($d, $comment->comment_date); |
|
| 512 | + } |
|
| 504 | 513 | /** |
| 505 | 514 | * Filter the returned comment date. |
| 506 | 515 | * |
@@ -653,8 +662,9 @@ discard block |
||
| 653 | 662 | $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
| 654 | 663 | $args = wp_parse_args( $args, $defaults ); |
| 655 | 664 | |
| 656 | - if ( '' === $args['per_page'] && get_option('page_comments') ) |
|
| 657 | - $args['per_page'] = get_option('comments_per_page'); |
|
| 665 | + if ( '' === $args['per_page'] && get_option('page_comments') ) { |
|
| 666 | + $args['per_page'] = get_option('comments_per_page'); |
|
| 667 | + } |
|
| 658 | 668 | |
| 659 | 669 | if ( empty($args['per_page']) ) { |
| 660 | 670 | $args['per_page'] = 0; |
@@ -662,13 +672,15 @@ discard block |
||
| 662 | 672 | } |
| 663 | 673 | |
| 664 | 674 | if ( $args['per_page'] ) { |
| 665 | - if ( '' == $args['page'] ) |
|
| 666 | - $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); |
|
| 675 | + if ( '' == $args['page'] ) { |
|
| 676 | + $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); |
|
| 677 | + } |
|
| 667 | 678 | |
| 668 | - if ( $wp_rewrite->using_permalinks() ) |
|
| 669 | - $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' ); |
|
| 670 | - else |
|
| 671 | - $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); |
|
| 679 | + if ( $wp_rewrite->using_permalinks() ) { |
|
| 680 | + $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' ); |
|
| 681 | + } else { |
|
| 682 | + $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ); |
|
| 683 | + } |
|
| 672 | 684 | } else { |
| 673 | 685 | $link = get_permalink( $comment->comment_post_ID ); |
| 674 | 686 | } |
@@ -718,10 +730,12 @@ discard block |
||
| 718 | 730 | * @param string $deprecated_2 Not Used. |
| 719 | 731 | */ |
| 720 | 732 | function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
| 721 | - if ( !empty( $deprecated ) ) |
|
| 722 | - _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 723 | - if ( !empty( $deprecated_2 ) ) |
|
| 724 | - _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 733 | + if ( !empty( $deprecated ) ) { |
|
| 734 | + _deprecated_argument( __FUNCTION__, '0.72' ); |
|
| 735 | + } |
|
| 736 | + if ( !empty( $deprecated_2 ) ) { |
|
| 737 | + _deprecated_argument( __FUNCTION__, '1.3' ); |
|
| 738 | + } |
|
| 725 | 739 | echo esc_url( get_comments_link() ); |
| 726 | 740 | } |
| 727 | 741 | |
@@ -876,10 +890,11 @@ discard block |
||
| 876 | 890 | function get_comment_time( $d = '', $gmt = false, $translate = true ) { |
| 877 | 891 | global $comment; |
| 878 | 892 | $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; |
| 879 | - if ( '' == $d ) |
|
| 880 | - $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
| 881 | - else |
|
| 882 | - $date = mysql2date($d, $comment_date, $translate); |
|
| 893 | + if ( '' == $d ) { |
|
| 894 | + $date = mysql2date(get_option('time_format'), $comment_date, $translate); |
|
| 895 | + } else { |
|
| 896 | + $date = mysql2date($d, $comment_date, $translate); |
|
| 897 | + } |
|
| 883 | 898 | |
| 884 | 899 | /** |
| 885 | 900 | * Filter the returned comment time. |
@@ -916,8 +931,9 @@ discard block |
||
| 916 | 931 | */ |
| 917 | 932 | function get_comment_type( $comment_ID = 0 ) { |
| 918 | 933 | $comment = get_comment( $comment_ID ); |
| 919 | - if ( '' == $comment->comment_type ) |
|
| 920 | - $comment->comment_type = 'comment'; |
|
| 934 | + if ( '' == $comment->comment_type ) { |
|
| 935 | + $comment->comment_type = 'comment'; |
|
| 936 | + } |
|
| 921 | 937 | |
| 922 | 938 | /** |
| 923 | 939 | * Filter the returned comment type. |
@@ -942,9 +958,15 @@ discard block |
||
| 942 | 958 | * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
| 943 | 959 | */ |
| 944 | 960 | function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
| 945 | - if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
|
| 946 | - if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
|
| 947 | - if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
|
| 961 | + if ( false === $commenttxt ) { |
|
| 962 | + $commenttxt = _x( 'Comment', 'noun' ); |
|
| 963 | + } |
|
| 964 | + if ( false === $trackbacktxt ) { |
|
| 965 | + $trackbacktxt = __( 'Trackback' ); |
|
| 966 | + } |
|
| 967 | + if ( false === $pingbacktxt ) { |
|
| 968 | + $pingbacktxt = __( 'Pingback' ); |
|
| 969 | + } |
|
| 948 | 970 | $type = get_comment_type(); |
| 949 | 971 | switch( $type ) { |
| 950 | 972 | case 'trackback' : |
@@ -970,10 +992,11 @@ discard block |
||
| 970 | 992 | * @return string The trackback URL after being filtered. |
| 971 | 993 | */ |
| 972 | 994 | function get_trackback_url() { |
| 973 | - if ( '' != get_option('permalink_structure') ) |
|
| 974 | - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 975 | - else |
|
| 976 | - $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 995 | + if ( '' != get_option('permalink_structure') ) { |
|
| 996 | + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); |
|
| 997 | + } else { |
|
| 998 | + $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); |
|
| 999 | + } |
|
| 977 | 1000 | |
| 978 | 1001 | /** |
| 979 | 1002 | * Filter the returned trackback URL. |
@@ -995,13 +1018,15 @@ discard block |
||
| 995 | 1018 | * for the result instead. |
| 996 | 1019 | */ |
| 997 | 1020 | function trackback_url( $deprecated_echo = true ) { |
| 998 | - if ( $deprecated_echo !== true ) |
|
| 999 | - _deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') ); |
|
| 1000 | - if ( $deprecated_echo ) |
|
| 1001 | - echo get_trackback_url(); |
|
| 1002 | - else |
|
| 1003 | - return get_trackback_url(); |
|
| 1004 | -} |
|
| 1021 | + if ( $deprecated_echo !== true ) { |
|
| 1022 | + _deprecated_argument( __FUNCTION__, '2.5', __('Use <code>get_trackback_url()</code> instead if you do not want the value echoed.') ); |
|
| 1023 | + } |
|
| 1024 | + if ( $deprecated_echo ) { |
|
| 1025 | + echo get_trackback_url(); |
|
| 1026 | + } else { |
|
| 1027 | + return get_trackback_url(); |
|
| 1028 | + } |
|
| 1029 | + } |
|
| 1005 | 1030 | |
| 1006 | 1031 | /** |
| 1007 | 1032 | * Generate and display the RDF for the trackback information of current post. |
@@ -1146,11 +1171,13 @@ discard block |
||
| 1146 | 1171 | function comments_template( $file = '/comments.php', $separate_comments = false ) { |
| 1147 | 1172 | global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
| 1148 | 1173 | |
| 1149 | - if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
|
| 1150 | - return; |
|
| 1174 | + if ( !(is_single() || is_page() || $withcomments) || empty($post) ) { |
|
| 1175 | + return; |
|
| 1176 | + } |
|
| 1151 | 1177 | |
| 1152 | - if ( empty($file) ) |
|
| 1153 | - $file = '/comments.php'; |
|
| 1178 | + if ( empty($file) ) { |
|
| 1179 | + $file = '/comments.php'; |
|
| 1180 | + } |
|
| 1154 | 1181 | |
| 1155 | 1182 | $req = get_option('require_name_email'); |
| 1156 | 1183 | |
@@ -1214,8 +1241,9 @@ discard block |
||
| 1214 | 1241 | $overridden_cpage = true; |
| 1215 | 1242 | } |
| 1216 | 1243 | |
| 1217 | - if ( !defined('COMMENTS_TEMPLATE') ) |
|
| 1218 | - define('COMMENTS_TEMPLATE', true); |
|
| 1244 | + if ( !defined('COMMENTS_TEMPLATE') ) { |
|
| 1245 | + define('COMMENTS_TEMPLATE', true); |
|
| 1246 | + } |
|
| 1219 | 1247 | |
| 1220 | 1248 | $theme_template = STYLESHEETPATH . $file; |
| 1221 | 1249 | /** |
@@ -1226,13 +1254,15 @@ discard block |
||
| 1226 | 1254 | * @param string $theme_template The path to the theme template file. |
| 1227 | 1255 | */ |
| 1228 | 1256 | $include = apply_filters( 'comments_template', $theme_template ); |
| 1229 | - if ( file_exists( $include ) ) |
|
| 1230 | - require( $include ); |
|
| 1231 | - elseif ( file_exists( TEMPLATEPATH . $file ) ) |
|
| 1232 | - require( TEMPLATEPATH . $file ); |
|
| 1233 | - else // Backward compat code will be removed in a future release |
|
| 1257 | + if ( file_exists( $include ) ) { |
|
| 1258 | + require( $include ); |
|
| 1259 | + } elseif ( file_exists( TEMPLATEPATH . $file ) ) { |
|
| 1260 | + require( TEMPLATEPATH . $file ); |
|
| 1261 | + } else { |
|
| 1262 | + // Backward compat code will be removed in a future release |
|
| 1234 | 1263 | require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
| 1235 | -} |
|
| 1264 | + } |
|
| 1265 | + } |
|
| 1236 | 1266 | |
| 1237 | 1267 | /** |
| 1238 | 1268 | * Display the JS popup script to show a comment. |
@@ -1326,17 +1356,19 @@ discard block |
||
| 1326 | 1356 | |
| 1327 | 1357 | echo '<a href="'; |
| 1328 | 1358 | if ( $wpcommentsjavascript ) { |
| 1329 | - if ( empty( $wpcommentspopupfile ) ) |
|
| 1330 | - $home = home_url(); |
|
| 1331 | - else |
|
| 1332 | - $home = get_option('siteurl'); |
|
| 1359 | + if ( empty( $wpcommentspopupfile ) ) { |
|
| 1360 | + $home = home_url(); |
|
| 1361 | + } else { |
|
| 1362 | + $home = get_option('siteurl'); |
|
| 1363 | + } |
|
| 1333 | 1364 | echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; |
| 1334 | 1365 | echo '" onclick="wpopen(this.href); return false"'; |
| 1335 | 1366 | } else { // if comments_popup_script() is not in the template, display simple comment link |
| 1336 | - if ( 0 == $number ) |
|
| 1337 | - echo get_permalink() . '#respond'; |
|
| 1338 | - else |
|
| 1339 | - comments_link(); |
|
| 1367 | + if ( 0 == $number ) { |
|
| 1368 | + echo get_permalink() . '#respond'; |
|
| 1369 | + } else { |
|
| 1370 | + comments_link(); |
|
| 1371 | + } |
|
| 1340 | 1372 | echo '"'; |
| 1341 | 1373 | } |
| 1342 | 1374 | |
@@ -1568,8 +1600,9 @@ discard block |
||
| 1568 | 1600 | * @return string |
| 1569 | 1601 | */ |
| 1570 | 1602 | function get_cancel_comment_reply_link( $text = '' ) { |
| 1571 | - if ( empty($text) ) |
|
| 1572 | - $text = __('Click here to cancel reply.'); |
|
| 1603 | + if ( empty($text) ) { |
|
| 1604 | + $text = __('Click here to cancel reply.'); |
|
| 1605 | + } |
|
| 1573 | 1606 | |
| 1574 | 1607 | $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; |
| 1575 | 1608 | $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; |
@@ -1607,8 +1640,9 @@ discard block |
||
| 1607 | 1640 | * @return string Hidden input HTML for replying to comments |
| 1608 | 1641 | */ |
| 1609 | 1642 | function get_comment_id_fields( $id = 0 ) { |
| 1610 | - if ( empty( $id ) ) |
|
| 1611 | - $id = get_the_ID(); |
|
| 1643 | + if ( empty( $id ) ) { |
|
| 1644 | + $id = get_the_ID(); |
|
| 1645 | + } |
|
| 1612 | 1646 | |
| 1613 | 1647 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1614 | 1648 | $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; |
@@ -1657,14 +1691,18 @@ discard block |
||
| 1657 | 1691 | function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
| 1658 | 1692 | global $comment; |
| 1659 | 1693 | |
| 1660 | - if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
|
| 1661 | - if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
|
| 1694 | + if ( false === $noreplytext ) { |
|
| 1695 | + $noreplytext = __( 'Leave a Reply' ); |
|
| 1696 | + } |
|
| 1697 | + if ( false === $replytext ) { |
|
| 1698 | + $replytext = __( 'Leave a Reply to %s' ); |
|
| 1699 | + } |
|
| 1662 | 1700 | |
| 1663 | 1701 | $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
| 1664 | 1702 | |
| 1665 | - if ( 0 == $replytoid ) |
|
| 1666 | - echo $noreplytext; |
|
| 1667 | - else { |
|
| 1703 | + if ( 0 == $replytoid ) { |
|
| 1704 | + echo $noreplytext; |
|
| 1705 | + } else { |
|
| 1668 | 1706 | $comment = get_comment($replytoid); |
| 1669 | 1707 | $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author() . '</a>' : get_comment_author(); |
| 1670 | 1708 | printf( $replytext, $author ); |
@@ -1788,8 +1826,9 @@ discard block |
||
| 1788 | 1826 | * @param string $output Passed by reference. Used to append additional content. |
| 1789 | 1827 | */ |
| 1790 | 1828 | public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { |
| 1791 | - if ( !$element ) |
|
| 1792 | - return; |
|
| 1829 | + if ( !$element ) { |
|
| 1830 | + return; |
|
| 1831 | + } |
|
| 1793 | 1832 | |
| 1794 | 1833 | $id_field = $this->db_fields['id']; |
| 1795 | 1834 | $id = $element->$id_field; |
@@ -1799,8 +1838,9 @@ discard block |
||
| 1799 | 1838 | // If we're at the max depth, and the current element still has children, loop over those and display them at this level |
| 1800 | 1839 | // This is to prevent them being orphaned to the end of the list. |
| 1801 | 1840 | if ( $max_depth <= $depth + 1 && isset( $children_elements[$id]) ) { |
| 1802 | - foreach ( $children_elements[ $id ] as $child ) |
|
| 1803 | - $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); |
|
| 1841 | + foreach ( $children_elements[ $id ] as $child ) { |
|
| 1842 | + $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); |
|
| 1843 | + } |
|
| 1804 | 1844 | |
| 1805 | 1845 | unset( $children_elements[ $id ] ); |
| 1806 | 1846 | } |
@@ -1870,10 +1910,11 @@ discard block |
||
| 1870 | 1910 | $output .= ob_get_clean(); |
| 1871 | 1911 | return; |
| 1872 | 1912 | } |
| 1873 | - if ( 'div' == $args['style'] ) |
|
| 1874 | - $output .= "</div><!-- #comment-## -->\n"; |
|
| 1875 | - else |
|
| 1876 | - $output .= "</li><!-- #comment-## -->\n"; |
|
| 1913 | + if ( 'div' == $args['style'] ) { |
|
| 1914 | + $output .= "</div><!-- #comment-## -->\n"; |
|
| 1915 | + } else { |
|
| 1916 | + $output .= "</li><!-- #comment-## -->\n"; |
|
| 1917 | + } |
|
| 1877 | 1918 | } |
| 1878 | 1919 | |
| 1879 | 1920 | /** |
@@ -1924,7 +1965,10 @@ discard block |
||
| 1924 | 1965 | <div id="div-comment-<?php comment_ID(); ?>" class="comment-body"> |
| 1925 | 1966 | <?php endif; ?> |
| 1926 | 1967 | <div class="comment-author vcard"> |
| 1927 | - <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
|
| 1968 | + <?php if ( 0 != $args['avatar_size'] ) { |
|
| 1969 | + echo get_avatar( $comment, $args['avatar_size'] ); |
|
| 1970 | +} |
|
| 1971 | +?> |
|
| 1928 | 1972 | <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?> |
| 1929 | 1973 | </div> |
| 1930 | 1974 | <?php if ( '0' == $comment->comment_approved ) : ?> |
@@ -1976,7 +2020,10 @@ discard block |
||
| 1976 | 2020 | <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> |
| 1977 | 2021 | <footer class="comment-meta"> |
| 1978 | 2022 | <div class="comment-author vcard"> |
| 1979 | - <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> |
|
| 2023 | + <?php if ( 0 != $args['avatar_size'] ) { |
|
| 2024 | + echo get_avatar( $comment, $args['avatar_size'] ); |
|
| 2025 | +} |
|
| 2026 | +?> |
|
| 1980 | 2027 | <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?> |
| 1981 | 2028 | </div><!-- .comment-author --> |
| 1982 | 2029 | |
@@ -2091,32 +2138,38 @@ discard block |
||
| 2091 | 2138 | // Figure out what comments we'll be looping through ($_comments) |
| 2092 | 2139 | if ( null !== $comments ) { |
| 2093 | 2140 | $comments = (array) $comments; |
| 2094 | - if ( empty($comments) ) |
|
| 2095 | - return; |
|
| 2141 | + if ( empty($comments) ) { |
|
| 2142 | + return; |
|
| 2143 | + } |
|
| 2096 | 2144 | if ( 'all' != $r['type'] ) { |
| 2097 | 2145 | $comments_by_type = separate_comments($comments); |
| 2098 | - if ( empty($comments_by_type[$r['type']]) ) |
|
| 2099 | - return; |
|
| 2146 | + if ( empty($comments_by_type[$r['type']]) ) { |
|
| 2147 | + return; |
|
| 2148 | + } |
|
| 2100 | 2149 | $_comments = $comments_by_type[$r['type']]; |
| 2101 | 2150 | } else { |
| 2102 | 2151 | $_comments = $comments; |
| 2103 | 2152 | } |
| 2104 | 2153 | } else { |
| 2105 | - if ( empty($wp_query->comments) ) |
|
| 2106 | - return; |
|
| 2154 | + if ( empty($wp_query->comments) ) { |
|
| 2155 | + return; |
|
| 2156 | + } |
|
| 2107 | 2157 | if ( 'all' != $r['type'] ) { |
| 2108 | - if ( empty($wp_query->comments_by_type) ) |
|
| 2109 | - $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
| 2110 | - if ( empty($wp_query->comments_by_type[$r['type']]) ) |
|
| 2111 | - return; |
|
| 2158 | + if ( empty($wp_query->comments_by_type) ) { |
|
| 2159 | + $wp_query->comments_by_type = separate_comments($wp_query->comments); |
|
| 2160 | + } |
|
| 2161 | + if ( empty($wp_query->comments_by_type[$r['type']]) ) { |
|
| 2162 | + return; |
|
| 2163 | + } |
|
| 2112 | 2164 | $_comments = $wp_query->comments_by_type[$r['type']]; |
| 2113 | 2165 | } else { |
| 2114 | 2166 | $_comments = $wp_query->comments; |
| 2115 | 2167 | } |
| 2116 | 2168 | } |
| 2117 | 2169 | |
| 2118 | - if ( '' === $r['per_page'] && get_option('page_comments') ) |
|
| 2119 | - $r['per_page'] = get_query_var('comments_per_page'); |
|
| 2170 | + if ( '' === $r['per_page'] && get_option('page_comments') ) { |
|
| 2171 | + $r['per_page'] = get_query_var('comments_per_page'); |
|
| 2172 | + } |
|
| 2120 | 2173 | |
| 2121 | 2174 | if ( empty($r['per_page']) ) { |
| 2122 | 2175 | $r['per_page'] = 0; |
@@ -2124,10 +2177,11 @@ discard block |
||
| 2124 | 2177 | } |
| 2125 | 2178 | |
| 2126 | 2179 | if ( '' === $r['max_depth'] ) { |
| 2127 | - if ( get_option('thread_comments') ) |
|
| 2128 | - $r['max_depth'] = get_option('thread_comments_depth'); |
|
| 2129 | - else |
|
| 2130 | - $r['max_depth'] = -1; |
|
| 2180 | + if ( get_option('thread_comments') ) { |
|
| 2181 | + $r['max_depth'] = get_option('thread_comments_depth'); |
|
| 2182 | + } else { |
|
| 2183 | + $r['max_depth'] = -1; |
|
| 2184 | + } |
|
| 2131 | 2185 | } |
| 2132 | 2186 | |
| 2133 | 2187 | if ( '' === $r['page'] ) { |
@@ -2141,11 +2195,13 @@ discard block |
||
| 2141 | 2195 | } |
| 2142 | 2196 | // Validation check |
| 2143 | 2197 | $r['page'] = intval($r['page']); |
| 2144 | - if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
|
| 2145 | - $r['page'] = 1; |
|
| 2198 | + if ( 0 == $r['page'] && 0 != $r['per_page'] ) { |
|
| 2199 | + $r['page'] = 1; |
|
| 2200 | + } |
|
| 2146 | 2201 | |
| 2147 | - if ( null === $r['reverse_top_level'] ) |
|
| 2148 | - $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2202 | + if ( null === $r['reverse_top_level'] ) { |
|
| 2203 | + $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
|
| 2204 | + } |
|
| 2149 | 2205 | |
| 2150 | 2206 | if ( empty( $r['walker'] ) ) { |
| 2151 | 2207 | $walker = new Walker_Comment; |
@@ -2214,16 +2270,18 @@ discard block |
||
| 2214 | 2270 | * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
| 2215 | 2271 | */ |
| 2216 | 2272 | function comment_form( $args = array(), $post_id = null ) { |
| 2217 | - if ( null === $post_id ) |
|
| 2218 | - $post_id = get_the_ID(); |
|
| 2273 | + if ( null === $post_id ) { |
|
| 2274 | + $post_id = get_the_ID(); |
|
| 2275 | + } |
|
| 2219 | 2276 | |
| 2220 | 2277 | $commenter = wp_get_current_commenter(); |
| 2221 | 2278 | $user = wp_get_current_user(); |
| 2222 | 2279 | $user_identity = $user->exists() ? $user->display_name : ''; |
| 2223 | 2280 | |
| 2224 | 2281 | $args = wp_parse_args( $args ); |
| 2225 | - if ( ! isset( $args['format'] ) ) |
|
| 2226 | - $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2282 | + if ( ! isset( $args['format'] ) ) { |
|
| 2283 | + $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
| 2284 | + } |
|
| 2227 | 2285 | |
| 2228 | 2286 | $req = get_option( 'require_name_email' ); |
| 2229 | 2287 | $aria_req = ( $req ? " aria-required='true'" : '' ); |
@@ -2305,8 +2363,11 @@ discard block |
||
| 2305 | 2363 | */ |
| 2306 | 2364 | do_action( 'comment_form_must_log_in_after' ); |
| 2307 | 2365 | ?> |
| 2308 | - <?php else : ?> |
|
| 2309 | - <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2366 | + <?php else { |
|
| 2367 | + : ?> |
|
| 2368 | + <form action="<?php echo site_url( '/wp-comments-post.php' ); |
|
| 2369 | +} |
|
| 2370 | +?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> |
|
| 2310 | 2371 | <?php |
| 2311 | 2372 | /** |
| 2312 | 2373 | * Fires at the top of the comment form, inside the form tag. |
@@ -2343,8 +2404,11 @@ discard block |
||
| 2343 | 2404 | */ |
| 2344 | 2405 | do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); |
| 2345 | 2406 | ?> |
| 2346 | - <?php else : ?> |
|
| 2347 | - <?php echo $args['comment_notes_before']; ?> |
|
| 2407 | + <?php else { |
|
| 2408 | + : ?> |
|
| 2409 | + <?php echo $args['comment_notes_before']; |
|
| 2410 | +} |
|
| 2411 | +?> |
|
| 2348 | 2412 | <?php |
| 2349 | 2413 | /** |
| 2350 | 2414 | * Fires before the comment fields in the comment form. |
@@ -2442,12 +2506,14 @@ discard block |
||
| 2442 | 2506 | * @since 3.0.0 |
| 2443 | 2507 | */ |
| 2444 | 2508 | do_action( 'comment_form_after' ); |
| 2445 | - else : |
|
| 2509 | + else { |
|
| 2510 | + : |
|
| 2446 | 2511 | /** |
| 2447 | 2512 | * Fires after the comment form if comments are closed. |
| 2448 | 2513 | * |
| 2449 | 2514 | * @since 3.0.0 |
| 2450 | 2515 | */ |
| 2451 | 2516 | do_action( 'comment_form_comments_closed' ); |
| 2517 | + } |
|
| 2452 | 2518 | endif; |
| 2453 | 2519 | } |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * @global wpdb $wpdb |
| 913 | 913 | * |
| 914 | 914 | * @param string $string |
| 915 | - * @param array $cols |
|
| 915 | + * @param string[] $cols |
|
| 916 | 916 | * @return string |
| 917 | 917 | */ |
| 918 | 918 | protected function get_search_sql( $string, $cols ) { |
@@ -3111,7 +3111,7 @@ discard block |
||
| 3111 | 3111 | * |
| 3112 | 3112 | * @param WP_Post $posts Post data object. |
| 3113 | 3113 | * @param WP_Query $query Query object. |
| 3114 | - * @return array |
|
| 3114 | + * @return WP_Post |
|
| 3115 | 3115 | */ |
| 3116 | 3116 | function _close_comments_for_old_posts( $posts, $query ) { |
| 3117 | 3117 | if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
@@ -40,15 +40,15 @@ discard block |
||
| 40 | 40 | global $wpdb; |
| 41 | 41 | |
| 42 | 42 | // If manual moderation is enabled, skip all checks and return false. |
| 43 | - if ( 1 == get_option('comment_moderation') ) |
|
| 43 | + if (1 == get_option('comment_moderation')) |
|
| 44 | 44 | return false; |
| 45 | 45 | |
| 46 | 46 | /** This filter is documented in wp-includes/comment-template.php */ |
| 47 | - $comment = apply_filters( 'comment_text', $comment ); |
|
| 47 | + $comment = apply_filters('comment_text', $comment); |
|
| 48 | 48 | |
| 49 | 49 | // Check for the number of external links if a max allowed number is set. |
| 50 | - if ( $max_links = get_option( 'comment_max_links' ) ) { |
|
| 51 | - $num_links = preg_match_all( '/<a [^>]*href/i', $comment, $out ); |
|
| 50 | + if ($max_links = get_option('comment_max_links')) { |
|
| 51 | + $num_links = preg_match_all('/<a [^>]*href/i', $comment, $out); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Filter the maximum number of links allowed in a comment. |
@@ -58,27 +58,27 @@ discard block |
||
| 58 | 58 | * @param int $num_links The number of links allowed. |
| 59 | 59 | * @param string $url Comment author's URL. Included in allowed links total. |
| 60 | 60 | */ |
| 61 | - $num_links = apply_filters( 'comment_max_links_url', $num_links, $url ); |
|
| 61 | + $num_links = apply_filters('comment_max_links_url', $num_links, $url); |
|
| 62 | 62 | |
| 63 | 63 | /* |
| 64 | 64 | * If the number of links in the comment exceeds the allowed amount, |
| 65 | 65 | * fail the check by returning false. |
| 66 | 66 | */ |
| 67 | - if ( $num_links >= $max_links ) |
|
| 67 | + if ($num_links >= $max_links) |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $mod_keys = trim(get_option('moderation_keys')); |
| 72 | 72 | |
| 73 | 73 | // If moderation 'keys' (keywords) are set, process them. |
| 74 | - if ( !empty($mod_keys) ) { |
|
| 75 | - $words = explode("\n", $mod_keys ); |
|
| 74 | + if ( ! empty($mod_keys)) { |
|
| 75 | + $words = explode("\n", $mod_keys); |
|
| 76 | 76 | |
| 77 | - foreach ( (array) $words as $word) { |
|
| 77 | + foreach ((array) $words as $word) { |
|
| 78 | 78 | $word = trim($word); |
| 79 | 79 | |
| 80 | 80 | // Skip empty lines. |
| 81 | - if ( empty($word) ) |
|
| 81 | + if (empty($word)) |
|
| 82 | 82 | continue; |
| 83 | 83 | |
| 84 | 84 | /* |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * fail the check for the given field by returning false. |
| 93 | 93 | */ |
| 94 | 94 | $pattern = "#$word#i"; |
| 95 | - if ( preg_match($pattern, $author) ) return false; |
|
| 96 | - if ( preg_match($pattern, $email) ) return false; |
|
| 97 | - if ( preg_match($pattern, $url) ) return false; |
|
| 98 | - if ( preg_match($pattern, $comment) ) return false; |
|
| 99 | - if ( preg_match($pattern, $user_ip) ) return false; |
|
| 100 | - if ( preg_match($pattern, $user_agent) ) return false; |
|
| 95 | + if (preg_match($pattern, $author)) return false; |
|
| 96 | + if (preg_match($pattern, $email)) return false; |
|
| 97 | + if (preg_match($pattern, $url)) return false; |
|
| 98 | + if (preg_match($pattern, $comment)) return false; |
|
| 99 | + if (preg_match($pattern, $user_ip)) return false; |
|
| 100 | + if (preg_match($pattern, $user_agent)) return false; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | * as well as whether there are any moderation keywords (if set) present in the author |
| 109 | 109 | * email address. If both checks pass, return true. Otherwise, return false. |
| 110 | 110 | */ |
| 111 | - if ( 1 == get_option('comment_whitelist')) { |
|
| 112 | - if ( 'trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '' ) { |
|
| 111 | + if (1 == get_option('comment_whitelist')) { |
|
| 112 | + if ('trackback' != $comment_type && 'pingback' != $comment_type && $author != '' && $email != '') { |
|
| 113 | 113 | // expected_slashed ($author, $email) |
| 114 | 114 | $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); |
| 115 | - if ( ( 1 == $ok_to_comment ) && |
|
| 116 | - ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) |
|
| 115 | + if ((1 == $ok_to_comment) && |
|
| 116 | + (empty($mod_keys) || false === strpos($email, $mod_keys))) |
|
| 117 | 117 | return true; |
| 118 | 118 | else |
| 119 | 119 | return false; |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * @return int|array $comments The approved comments, or number of comments if `$count` |
| 137 | 137 | * argument is true. |
| 138 | 138 | */ |
| 139 | -function get_approved_comments( $post_id, $args = array() ) { |
|
| 140 | - if ( ! $post_id ) { |
|
| 139 | +function get_approved_comments($post_id, $args = array()) { |
|
| 140 | + if ( ! $post_id) { |
|
| 141 | 141 | return array(); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | 'post_id' => $post_id, |
| 147 | 147 | 'order' => 'ASC', |
| 148 | 148 | ); |
| 149 | - $r = wp_parse_args( $args, $defaults ); |
|
| 149 | + $r = wp_parse_args($args, $defaults); |
|
| 150 | 150 | |
| 151 | 151 | $query = new WP_Comment_Query; |
| 152 | - return $query->query( $r ); |
|
| 152 | + return $query->query($r); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -171,20 +171,20 @@ discard block |
||
| 171 | 171 | function get_comment(&$comment, $output = OBJECT) { |
| 172 | 172 | global $wpdb; |
| 173 | 173 | |
| 174 | - if ( empty($comment) ) { |
|
| 175 | - if ( isset($GLOBALS['comment']) ) |
|
| 174 | + if (empty($comment)) { |
|
| 175 | + if (isset($GLOBALS['comment'])) |
|
| 176 | 176 | $_comment = & $GLOBALS['comment']; |
| 177 | 177 | else |
| 178 | 178 | $_comment = null; |
| 179 | - } elseif ( is_object($comment) ) { |
|
| 179 | + } elseif (is_object($comment)) { |
|
| 180 | 180 | wp_cache_add($comment->comment_ID, $comment, 'comment'); |
| 181 | 181 | $_comment = $comment; |
| 182 | 182 | } else { |
| 183 | - if ( isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment) ) { |
|
| 183 | + if (isset($GLOBALS['comment']) && ($GLOBALS['comment']->comment_ID == $comment)) { |
|
| 184 | 184 | $_comment = & $GLOBALS['comment']; |
| 185 | - } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { |
|
| 185 | + } elseif ( ! $_comment = wp_cache_get($comment, 'comment')) { |
|
| 186 | 186 | $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); |
| 187 | - if ( ! $_comment ) |
|
| 187 | + if ( ! $_comment) |
|
| 188 | 188 | return null; |
| 189 | 189 | wp_cache_add($_comment->comment_ID, $_comment, 'comment'); |
| 190 | 190 | } |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @param mixed $_comment Comment data. |
| 199 | 199 | */ |
| 200 | - $_comment = apply_filters( 'get_comment', $_comment ); |
|
| 200 | + $_comment = apply_filters('get_comment', $_comment); |
|
| 201 | 201 | |
| 202 | - if ( $output == OBJECT ) { |
|
| 202 | + if ($output == OBJECT) { |
|
| 203 | 203 | return $_comment; |
| 204 | - } elseif ( $output == ARRAY_A ) { |
|
| 204 | + } elseif ($output == ARRAY_A) { |
|
| 205 | 205 | $__comment = get_object_vars($_comment); |
| 206 | 206 | return $__comment; |
| 207 | - } elseif ( $output == ARRAY_N ) { |
|
| 207 | + } elseif ($output == ARRAY_N) { |
|
| 208 | 208 | $__comment = array_values(get_object_vars($_comment)); |
| 209 | 209 | return $__comment; |
| 210 | 210 | } else { |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | * for information on accepted arguments. Default empty. |
| 224 | 224 | * @return int|array List of comments or number of found comments if `$count` argument is true. |
| 225 | 225 | */ |
| 226 | -function get_comments( $args = '' ) { |
|
| 226 | +function get_comments($args = '') { |
|
| 227 | 227 | $query = new WP_Comment_Query; |
| 228 | - return $query->query( $args ); |
|
| 228 | + return $query->query($args); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | * @param array $arguments Arguments to pass when calling. |
| 301 | 301 | * @return mixed|false Return value of the callback, false otherwise. |
| 302 | 302 | */ |
| 303 | - public function __call( $name, $arguments ) { |
|
| 304 | - if ( 'get_search_sql' === $name ) { |
|
| 305 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 303 | + public function __call($name, $arguments) { |
|
| 304 | + if ('get_search_sql' === $name) { |
|
| 305 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 306 | 306 | } |
| 307 | 307 | return false; |
| 308 | 308 | } |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * @type int $user_id Include comments for a specific user ID. Default empty. |
| 380 | 380 | * } |
| 381 | 381 | */ |
| 382 | - public function __construct( $query = '' ) { |
|
| 382 | + public function __construct($query = '') { |
|
| 383 | 383 | $this->query_var_defaults = array( |
| 384 | 384 | 'author_email' => '', |
| 385 | 385 | 'author__in' => '', |
@@ -419,8 +419,8 @@ discard block |
||
| 419 | 419 | 'date_query' => null, // See WP_Date_Query |
| 420 | 420 | ); |
| 421 | 421 | |
| 422 | - if ( ! empty( $query ) ) { |
|
| 423 | - $this->query( $query ); |
|
| 422 | + if ( ! empty($query)) { |
|
| 423 | + $this->query($query); |
|
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
@@ -433,13 +433,13 @@ discard block |
||
| 433 | 433 | * |
| 434 | 434 | * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct() |
| 435 | 435 | */ |
| 436 | - public function parse_query( $query = '' ) { |
|
| 437 | - if ( empty( $query ) ) { |
|
| 436 | + public function parse_query($query = '') { |
|
| 437 | + if (empty($query)) { |
|
| 438 | 438 | $query = $this->query_vars; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - $this->query_vars = wp_parse_args( $query, $this->query_var_defaults ); |
|
| 442 | - do_action_ref_array( 'parse_comment_query', array( &$this ) ); |
|
| 441 | + $this->query_vars = wp_parse_args($query, $this->query_var_defaults); |
|
| 442 | + do_action_ref_array('parse_comment_query', array(&$this)); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -456,8 +456,8 @@ discard block |
||
| 456 | 456 | * @param string|array $query Array or URL query string of parameters. |
| 457 | 457 | * @return array|int List of comments, or number of comments when 'count' is passed as a query var. |
| 458 | 458 | */ |
| 459 | - public function query( $query ) { |
|
| 460 | - $this->query_vars = wp_parse_args( $query ); |
|
| 459 | + public function query($query) { |
|
| 460 | + $this->query_vars = wp_parse_args($query); |
|
| 461 | 461 | return $this->get_comments(); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | // Parse meta query |
| 482 | 482 | $this->meta_query = new WP_Meta_Query(); |
| 483 | - $this->meta_query->parse_query_vars( $this->query_vars ); |
|
| 483 | + $this->meta_query->parse_query_vars($this->query_vars); |
|
| 484 | 484 | |
| 485 | 485 | /** |
| 486 | 486 | * Fires before comments are retrieved. |
@@ -489,24 +489,24 @@ discard block |
||
| 489 | 489 | * |
| 490 | 490 | * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference. |
| 491 | 491 | */ |
| 492 | - do_action_ref_array( 'pre_get_comments', array( &$this ) ); |
|
| 492 | + do_action_ref_array('pre_get_comments', array(&$this)); |
|
| 493 | 493 | |
| 494 | 494 | // Reparse query vars, in case they were modified in a 'pre_get_comments' callback. |
| 495 | - $this->meta_query->parse_query_vars( $this->query_vars ); |
|
| 496 | - if ( ! empty( $this->meta_query->queries ) ) { |
|
| 497 | - $meta_query_clauses = $this->meta_query->get_sql( 'comment', $wpdb->comments, 'comment_ID', $this ); |
|
| 495 | + $this->meta_query->parse_query_vars($this->query_vars); |
|
| 496 | + if ( ! empty($this->meta_query->queries)) { |
|
| 497 | + $meta_query_clauses = $this->meta_query->get_sql('comment', $wpdb->comments, 'comment_ID', $this); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // $args can include anything. Only use the args defined in the query_var_defaults to compute the key. |
| 501 | - $key = md5( serialize( wp_array_slice_assoc( $this->query_vars, array_keys( $this->query_var_defaults ) ) ) ); |
|
| 502 | - $last_changed = wp_cache_get( 'last_changed', 'comment' ); |
|
| 503 | - if ( ! $last_changed ) { |
|
| 501 | + $key = md5(serialize(wp_array_slice_assoc($this->query_vars, array_keys($this->query_var_defaults)))); |
|
| 502 | + $last_changed = wp_cache_get('last_changed', 'comment'); |
|
| 503 | + if ( ! $last_changed) { |
|
| 504 | 504 | $last_changed = microtime(); |
| 505 | - wp_cache_set( 'last_changed', $last_changed, 'comment' ); |
|
| 505 | + wp_cache_set('last_changed', $last_changed, 'comment'); |
|
| 506 | 506 | } |
| 507 | 507 | $cache_key = "get_comments:$key:$last_changed"; |
| 508 | 508 | |
| 509 | - if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { |
|
| 509 | + if ($cache = wp_cache_get($cache_key, 'comment')) { |
|
| 510 | 510 | $this->comments = $cache; |
| 511 | 511 | return $this->comments; |
| 512 | 512 | } |
@@ -519,14 +519,14 @@ discard block |
||
| 519 | 519 | // 'status' accepts an array or a comma-separated string. |
| 520 | 520 | $status_clauses = array(); |
| 521 | 521 | $statuses = $this->query_vars['status']; |
| 522 | - if ( ! is_array( $statuses ) ) { |
|
| 523 | - $statuses = preg_split( '/[\s,]+/', $statuses ); |
|
| 522 | + if ( ! is_array($statuses)) { |
|
| 523 | + $statuses = preg_split('/[\s,]+/', $statuses); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | // 'any' overrides other statuses. |
| 527 | - if ( ! in_array( 'any', $statuses ) ) { |
|
| 528 | - foreach ( $statuses as $status ) { |
|
| 529 | - switch ( $status ) { |
|
| 527 | + if ( ! in_array('any', $statuses)) { |
|
| 528 | + foreach ($statuses as $status) { |
|
| 529 | + switch ($status) { |
|
| 530 | 530 | case 'hold' : |
| 531 | 531 | $status_clauses[] = "comment_approved = '0'"; |
| 532 | 532 | break; |
@@ -541,65 +541,64 @@ discard block |
||
| 541 | 541 | break; |
| 542 | 542 | |
| 543 | 543 | default : |
| 544 | - $status_clauses[] = $wpdb->prepare( "comment_approved = %s", $status ); |
|
| 544 | + $status_clauses[] = $wpdb->prepare("comment_approved = %s", $status); |
|
| 545 | 545 | break; |
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | - if ( ! empty( $status_clauses ) ) { |
|
| 550 | - $approved_clauses[] = '( ' . implode( ' OR ', $status_clauses ) . ' )'; |
|
| 549 | + if ( ! empty($status_clauses)) { |
|
| 550 | + $approved_clauses[] = '( '.implode(' OR ', $status_clauses).' )'; |
|
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | // User IDs or emails whose unapproved comments are included, regardless of $status. |
| 555 | - if ( ! empty( $this->query_vars['include_unapproved'] ) ) { |
|
| 555 | + if ( ! empty($this->query_vars['include_unapproved'])) { |
|
| 556 | 556 | $include_unapproved = $this->query_vars['include_unapproved']; |
| 557 | 557 | |
| 558 | 558 | // Accepts arrays or comma-separated strings. |
| 559 | - if ( ! is_array( $include_unapproved ) ) { |
|
| 560 | - $include_unapproved = preg_split( '/[\s,]+/', $include_unapproved ); |
|
| 559 | + if ( ! is_array($include_unapproved)) { |
|
| 560 | + $include_unapproved = preg_split('/[\s,]+/', $include_unapproved); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | $unapproved_ids = $unapproved_emails = array(); |
| 564 | - foreach ( $include_unapproved as $unapproved_identifier ) { |
|
| 564 | + foreach ($include_unapproved as $unapproved_identifier) { |
|
| 565 | 565 | // Numeric values are assumed to be user ids. |
| 566 | - if ( is_numeric( $unapproved_identifier ) ) { |
|
| 567 | - $approved_clauses[] = $wpdb->prepare( "( user_id = %d AND comment_approved = '0' )", $unapproved_identifier ); |
|
| 566 | + if (is_numeric($unapproved_identifier)) { |
|
| 567 | + $approved_clauses[] = $wpdb->prepare("( user_id = %d AND comment_approved = '0' )", $unapproved_identifier); |
|
| 568 | 568 | |
| 569 | 569 | // Otherwise we match against email addresses. |
| 570 | 570 | } else { |
| 571 | - $approved_clauses[] = $wpdb->prepare( "( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier ); |
|
| 571 | + $approved_clauses[] = $wpdb->prepare("( comment_author_email = %s AND comment_approved = '0' )", $unapproved_identifier); |
|
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | // Collapse comment_approved clauses into a single OR-separated clause. |
| 577 | - if ( ! empty( $approved_clauses ) ) { |
|
| 578 | - if ( 1 === count( $approved_clauses ) ) { |
|
| 577 | + if ( ! empty($approved_clauses)) { |
|
| 578 | + if (1 === count($approved_clauses)) { |
|
| 579 | 579 | $where[] = $approved_clauses[0]; |
| 580 | 580 | } else { |
| 581 | - $where[] = '( ' . implode( ' OR ', $approved_clauses ) . ' )'; |
|
| 581 | + $where[] = '( '.implode(' OR ', $approved_clauses).' )'; |
|
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - $order = ( 'ASC' == strtoupper( $this->query_vars['order'] ) ) ? 'ASC' : 'DESC'; |
|
| 585 | + $order = ('ASC' == strtoupper($this->query_vars['order'])) ? 'ASC' : 'DESC'; |
|
| 586 | 586 | |
| 587 | 587 | // Disable ORDER BY with 'none', an empty array, or boolean false. |
| 588 | - if ( in_array( $this->query_vars['orderby'], array( 'none', array(), false ), true ) ) { |
|
| 588 | + if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) { |
|
| 589 | 589 | $orderby = ''; |
| 590 | - } elseif ( ! empty( $this->query_vars['orderby'] ) ) { |
|
| 591 | - $ordersby = is_array( $this->query_vars['orderby'] ) ? |
|
| 592 | - $this->query_vars['orderby'] : |
|
| 593 | - preg_split( '/[,\s]/', $this->query_vars['orderby'] ); |
|
| 590 | + } elseif ( ! empty($this->query_vars['orderby'])) { |
|
| 591 | + $ordersby = is_array($this->query_vars['orderby']) ? |
|
| 592 | + $this->query_vars['orderby'] : preg_split('/[,\s]/', $this->query_vars['orderby']); |
|
| 594 | 593 | |
| 595 | 594 | $orderby_array = array(); |
| 596 | 595 | $found_orderby_comment_ID = false; |
| 597 | - foreach ( $ordersby as $_key => $_value ) { |
|
| 598 | - if ( ! $_value ) { |
|
| 596 | + foreach ($ordersby as $_key => $_value) { |
|
| 597 | + if ( ! $_value) { |
|
| 599 | 598 | continue; |
| 600 | 599 | } |
| 601 | 600 | |
| 602 | - if ( is_int( $_key ) ) { |
|
| 601 | + if (is_int($_key)) { |
|
| 603 | 602 | $_orderby = $_value; |
| 604 | 603 | $_order = $order; |
| 605 | 604 | } else { |
@@ -607,40 +606,40 @@ discard block |
||
| 607 | 606 | $_order = $_value; |
| 608 | 607 | } |
| 609 | 608 | |
| 610 | - if ( ! $found_orderby_comment_ID && 'comment_ID' === $_orderby ) { |
|
| 609 | + if ( ! $found_orderby_comment_ID && 'comment_ID' === $_orderby) { |
|
| 611 | 610 | $found_orderby_comment_ID = true; |
| 612 | 611 | } |
| 613 | 612 | |
| 614 | - $parsed = $this->parse_orderby( $_orderby ); |
|
| 613 | + $parsed = $this->parse_orderby($_orderby); |
|
| 615 | 614 | |
| 616 | - if ( ! $parsed ) { |
|
| 615 | + if ( ! $parsed) { |
|
| 617 | 616 | continue; |
| 618 | 617 | } |
| 619 | 618 | |
| 620 | - $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order ); |
|
| 619 | + $orderby_array[] = $parsed.' '.$this->parse_order($_order); |
|
| 621 | 620 | } |
| 622 | 621 | |
| 623 | 622 | // If no valid clauses were found, order by comment_date_gmt. |
| 624 | - if ( empty( $orderby_array ) ) { |
|
| 623 | + if (empty($orderby_array)) { |
|
| 625 | 624 | $orderby_array[] = "$wpdb->comments.comment_date_gmt $order"; |
| 626 | 625 | } |
| 627 | 626 | |
| 628 | 627 | // To ensure determinate sorting, always include a comment_ID clause. |
| 629 | - if ( ! $found_orderby_comment_ID ) { |
|
| 628 | + if ( ! $found_orderby_comment_ID) { |
|
| 630 | 629 | $comment_ID_order = ''; |
| 631 | 630 | |
| 632 | 631 | // Inherit order from comment_date or comment_date_gmt, if available. |
| 633 | - foreach ( $orderby_array as $orderby_clause ) { |
|
| 634 | - if ( preg_match( '/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match ) ) { |
|
| 632 | + foreach ($orderby_array as $orderby_clause) { |
|
| 633 | + if (preg_match('/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match)) { |
|
| 635 | 634 | $comment_ID_order = $match[1]; |
| 636 | 635 | break; |
| 637 | 636 | } |
| 638 | 637 | } |
| 639 | 638 | |
| 640 | 639 | // If no date-related order is available, use the date from the first available clause. |
| 641 | - if ( ! $comment_ID_order ) { |
|
| 642 | - foreach ( $orderby_array as $orderby_clause ) { |
|
| 643 | - if ( false !== strpos( 'ASC', $orderby_clause ) ) { |
|
| 640 | + if ( ! $comment_ID_order) { |
|
| 641 | + foreach ($orderby_array as $orderby_clause) { |
|
| 642 | + if (false !== strpos('ASC', $orderby_clause)) { |
|
| 644 | 643 | $comment_ID_order = 'ASC'; |
| 645 | 644 | } else { |
| 646 | 645 | $comment_ID_order = 'DESC'; |
@@ -651,35 +650,35 @@ discard block |
||
| 651 | 650 | } |
| 652 | 651 | |
| 653 | 652 | // Default to DESC. |
| 654 | - if ( ! $comment_ID_order ) { |
|
| 653 | + if ( ! $comment_ID_order) { |
|
| 655 | 654 | $comment_ID_order = 'DESC'; |
| 656 | 655 | } |
| 657 | 656 | |
| 658 | 657 | $orderby_array[] = "$wpdb->comments.comment_ID $comment_ID_order"; |
| 659 | 658 | } |
| 660 | 659 | |
| 661 | - $orderby = implode( ', ', $orderby_array ); |
|
| 660 | + $orderby = implode(', ', $orderby_array); |
|
| 662 | 661 | } else { |
| 663 | 662 | $orderby = "$wpdb->comments.comment_date_gmt $order"; |
| 664 | 663 | } |
| 665 | 664 | |
| 666 | - $number = absint( $this->query_vars['number'] ); |
|
| 667 | - $offset = absint( $this->query_vars['offset'] ); |
|
| 665 | + $number = absint($this->query_vars['number']); |
|
| 666 | + $offset = absint($this->query_vars['offset']); |
|
| 668 | 667 | |
| 669 | - if ( ! empty( $number ) ) { |
|
| 670 | - if ( $offset ) { |
|
| 671 | - $limits = 'LIMIT ' . $offset . ',' . $number; |
|
| 668 | + if ( ! empty($number)) { |
|
| 669 | + if ($offset) { |
|
| 670 | + $limits = 'LIMIT '.$offset.','.$number; |
|
| 672 | 671 | } else { |
| 673 | - $limits = 'LIMIT ' . $number; |
|
| 672 | + $limits = 'LIMIT '.$number; |
|
| 674 | 673 | } |
| 675 | 674 | } else { |
| 676 | 675 | $limits = ''; |
| 677 | 676 | } |
| 678 | 677 | |
| 679 | - if ( $this->query_vars['count'] ) { |
|
| 678 | + if ($this->query_vars['count']) { |
|
| 680 | 679 | $fields = 'COUNT(*)'; |
| 681 | 680 | } else { |
| 682 | - switch ( strtolower( $this->query_vars['fields'] ) ) { |
|
| 681 | + switch (strtolower($this->query_vars['fields'])) { |
|
| 683 | 682 | case 'ids': |
| 684 | 683 | $fields = "$wpdb->comments.comment_ID"; |
| 685 | 684 | break; |
@@ -691,51 +690,51 @@ discard block |
||
| 691 | 690 | |
| 692 | 691 | $join = ''; |
| 693 | 692 | |
| 694 | - $post_id = absint( $this->query_vars['post_id'] ); |
|
| 695 | - if ( ! empty( $post_id ) ) { |
|
| 696 | - $where[] = $wpdb->prepare( 'comment_post_ID = %d', $post_id ); |
|
| 693 | + $post_id = absint($this->query_vars['post_id']); |
|
| 694 | + if ( ! empty($post_id)) { |
|
| 695 | + $where[] = $wpdb->prepare('comment_post_ID = %d', $post_id); |
|
| 697 | 696 | } |
| 698 | 697 | |
| 699 | 698 | // Parse comment IDs for an IN clause. |
| 700 | - if ( ! empty( $this->query_vars['comment__in'] ) ) { |
|
| 701 | - $where[] = "$wpdb->comments.comment_ID IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__in'] ) ) . ' )'; |
|
| 699 | + if ( ! empty($this->query_vars['comment__in'])) { |
|
| 700 | + $where[] = "$wpdb->comments.comment_ID IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__in'])).' )'; |
|
| 702 | 701 | } |
| 703 | 702 | |
| 704 | 703 | // Parse comment IDs for a NOT IN clause. |
| 705 | - if ( ! empty( $this->query_vars['comment__not_in'] ) ) { |
|
| 706 | - $where[] = "$wpdb->comments.comment_ID NOT IN ( " . implode( ',', wp_parse_id_list( $this->query_vars['comment__not_in'] ) ) . ' )'; |
|
| 704 | + if ( ! empty($this->query_vars['comment__not_in'])) { |
|
| 705 | + $where[] = "$wpdb->comments.comment_ID NOT IN ( ".implode(',', wp_parse_id_list($this->query_vars['comment__not_in'])).' )'; |
|
| 707 | 706 | } |
| 708 | 707 | |
| 709 | 708 | // Parse comment post IDs for an IN clause. |
| 710 | - if ( ! empty( $this->query_vars['post__in'] ) ) { |
|
| 711 | - $where[] = 'comment_post_ID IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__in'] ) ) . ' )'; |
|
| 709 | + if ( ! empty($this->query_vars['post__in'])) { |
|
| 710 | + $where[] = 'comment_post_ID IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__in'])).' )'; |
|
| 712 | 711 | } |
| 713 | 712 | |
| 714 | 713 | // Parse comment post IDs for a NOT IN clause. |
| 715 | - if ( ! empty( $this->query_vars['post__not_in'] ) ) { |
|
| 716 | - $where[] = 'comment_post_ID NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post__not_in'] ) ) . ' )'; |
|
| 714 | + if ( ! empty($this->query_vars['post__not_in'])) { |
|
| 715 | + $where[] = 'comment_post_ID NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post__not_in'])).' )'; |
|
| 717 | 716 | } |
| 718 | 717 | |
| 719 | - if ( '' !== $this->query_vars['author_email'] ) { |
|
| 720 | - $where[] = $wpdb->prepare( 'comment_author_email = %s', $this->query_vars['author_email'] ); |
|
| 718 | + if ('' !== $this->query_vars['author_email']) { |
|
| 719 | + $where[] = $wpdb->prepare('comment_author_email = %s', $this->query_vars['author_email']); |
|
| 721 | 720 | } |
| 722 | 721 | |
| 723 | - if ( '' !== $this->query_vars['karma'] ) { |
|
| 724 | - $where[] = $wpdb->prepare( 'comment_karma = %d', $this->query_vars['karma'] ); |
|
| 722 | + if ('' !== $this->query_vars['karma']) { |
|
| 723 | + $where[] = $wpdb->prepare('comment_karma = %d', $this->query_vars['karma']); |
|
| 725 | 724 | } |
| 726 | 725 | |
| 727 | 726 | // Filtering by comment_type: 'type', 'type__in', 'type__not_in'. |
| 728 | 727 | $raw_types = array( |
| 729 | - 'IN' => array_merge( (array) $this->query_vars['type'], (array) $this->query_vars['type__in'] ), |
|
| 728 | + 'IN' => array_merge((array) $this->query_vars['type'], (array) $this->query_vars['type__in']), |
|
| 730 | 729 | 'NOT IN' => (array) $this->query_vars['type__not_in'], |
| 731 | 730 | ); |
| 732 | 731 | |
| 733 | 732 | $comment_types = array(); |
| 734 | - foreach ( $raw_types as $operator => $_raw_types ) { |
|
| 735 | - $_raw_types = array_unique( $_raw_types ); |
|
| 733 | + foreach ($raw_types as $operator => $_raw_types) { |
|
| 734 | + $_raw_types = array_unique($_raw_types); |
|
| 736 | 735 | |
| 737 | - foreach ( $_raw_types as $type ) { |
|
| 738 | - switch ( $type ) { |
|
| 736 | + foreach ($_raw_types as $type) { |
|
| 737 | + switch ($type) { |
|
| 739 | 738 | // An empty translates to 'all', for backward compatibility |
| 740 | 739 | case '': |
| 741 | 740 | case 'all' : |
@@ -743,106 +742,106 @@ discard block |
||
| 743 | 742 | |
| 744 | 743 | case 'comment': |
| 745 | 744 | case 'comments': |
| 746 | - $comment_types[ $operator ][] = "''"; |
|
| 745 | + $comment_types[$operator][] = "''"; |
|
| 747 | 746 | break; |
| 748 | 747 | |
| 749 | 748 | case 'pings': |
| 750 | - $comment_types[ $operator ][] = "'pingback'"; |
|
| 751 | - $comment_types[ $operator ][] = "'trackback'"; |
|
| 749 | + $comment_types[$operator][] = "'pingback'"; |
|
| 750 | + $comment_types[$operator][] = "'trackback'"; |
|
| 752 | 751 | break; |
| 753 | 752 | |
| 754 | 753 | default: |
| 755 | - $comment_types[ $operator ][] = $wpdb->prepare( '%s', $type ); |
|
| 754 | + $comment_types[$operator][] = $wpdb->prepare('%s', $type); |
|
| 756 | 755 | break; |
| 757 | 756 | } |
| 758 | 757 | } |
| 759 | 758 | |
| 760 | - if ( ! empty( $comment_types[ $operator ] ) ) { |
|
| 761 | - $types_sql = implode( ', ', $comment_types[ $operator ] ); |
|
| 759 | + if ( ! empty($comment_types[$operator])) { |
|
| 760 | + $types_sql = implode(', ', $comment_types[$operator]); |
|
| 762 | 761 | $where[] = "comment_type $operator ($types_sql)"; |
| 763 | 762 | } |
| 764 | 763 | } |
| 765 | 764 | |
| 766 | - if ( '' !== $this->query_vars['parent'] ) { |
|
| 767 | - $where[] = $wpdb->prepare( 'comment_parent = %d', $this->query_vars['parent'] ); |
|
| 765 | + if ('' !== $this->query_vars['parent']) { |
|
| 766 | + $where[] = $wpdb->prepare('comment_parent = %d', $this->query_vars['parent']); |
|
| 768 | 767 | } |
| 769 | 768 | |
| 770 | - if ( is_array( $this->query_vars['user_id'] ) ) { |
|
| 771 | - $where[] = 'user_id IN (' . implode( ',', array_map( 'absint', $this->query_vars['user_id'] ) ) . ')'; |
|
| 772 | - } elseif ( '' !== $this->query_vars['user_id'] ) { |
|
| 773 | - $where[] = $wpdb->prepare( 'user_id = %d', $this->query_vars['user_id'] ); |
|
| 769 | + if (is_array($this->query_vars['user_id'])) { |
|
| 770 | + $where[] = 'user_id IN ('.implode(',', array_map('absint', $this->query_vars['user_id'])).')'; |
|
| 771 | + } elseif ('' !== $this->query_vars['user_id']) { |
|
| 772 | + $where[] = $wpdb->prepare('user_id = %d', $this->query_vars['user_id']); |
|
| 774 | 773 | } |
| 775 | 774 | |
| 776 | - if ( '' !== $this->query_vars['search'] ) { |
|
| 775 | + if ('' !== $this->query_vars['search']) { |
|
| 777 | 776 | $search_sql = $this->get_search_sql( |
| 778 | 777 | $this->query_vars['search'], |
| 779 | - array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content' ) |
|
| 778 | + array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_content') |
|
| 780 | 779 | ); |
| 781 | 780 | |
| 782 | 781 | // Strip leading 'AND'. |
| 783 | - $where[] = preg_replace( '/^\s*AND\s*/', '', $search_sql ); |
|
| 782 | + $where[] = preg_replace('/^\s*AND\s*/', '', $search_sql); |
|
| 784 | 783 | } |
| 785 | 784 | |
| 786 | 785 | // If any post-related query vars are passed, join the posts table. |
| 787 | 786 | $join_posts_table = false; |
| 788 | - $plucked = wp_array_slice_assoc( $this->query_vars, array( 'post_author', 'post_name', 'post_parent', 'post_status', 'post_type' ) ); |
|
| 789 | - $post_fields = array_filter( $plucked ); |
|
| 787 | + $plucked = wp_array_slice_assoc($this->query_vars, array('post_author', 'post_name', 'post_parent', 'post_status', 'post_type')); |
|
| 788 | + $post_fields = array_filter($plucked); |
|
| 790 | 789 | |
| 791 | - if ( ! empty( $post_fields ) ) { |
|
| 790 | + if ( ! empty($post_fields)) { |
|
| 792 | 791 | $join_posts_table = true; |
| 793 | - foreach ( $post_fields as $field_name => $field_value ) { |
|
| 792 | + foreach ($post_fields as $field_name => $field_value) { |
|
| 794 | 793 | // $field_value may be an array. |
| 795 | - $esses = array_fill( 0, count( (array) $field_value ), '%s' ); |
|
| 796 | - $where[] = $wpdb->prepare( " {$wpdb->posts}.{$field_name} IN (" . implode( ',', $esses ) . ')', $field_value ); |
|
| 794 | + $esses = array_fill(0, count((array) $field_value), '%s'); |
|
| 795 | + $where[] = $wpdb->prepare(" {$wpdb->posts}.{$field_name} IN (".implode(',', $esses).')', $field_value); |
|
| 797 | 796 | } |
| 798 | 797 | } |
| 799 | 798 | |
| 800 | 799 | // Comment author IDs for an IN clause. |
| 801 | - if ( ! empty( $this->query_vars['author__in'] ) ) { |
|
| 802 | - $where[] = 'user_id IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__in'] ) ) . ' )'; |
|
| 800 | + if ( ! empty($this->query_vars['author__in'])) { |
|
| 801 | + $where[] = 'user_id IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__in'])).' )'; |
|
| 803 | 802 | } |
| 804 | 803 | |
| 805 | 804 | // Comment author IDs for a NOT IN clause. |
| 806 | - if ( ! empty( $this->query_vars['author__not_in'] ) ) { |
|
| 807 | - $where[] = 'user_id NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['author__not_in'] ) ) . ' )'; |
|
| 805 | + if ( ! empty($this->query_vars['author__not_in'])) { |
|
| 806 | + $where[] = 'user_id NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['author__not_in'])).' )'; |
|
| 808 | 807 | } |
| 809 | 808 | |
| 810 | 809 | // Post author IDs for an IN clause. |
| 811 | - if ( ! empty( $this->query_vars['post_author__in'] ) ) { |
|
| 810 | + if ( ! empty($this->query_vars['post_author__in'])) { |
|
| 812 | 811 | $join_posts_table = true; |
| 813 | - $where[] = 'post_author IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__in'] ) ) . ' )'; |
|
| 812 | + $where[] = 'post_author IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__in'])).' )'; |
|
| 814 | 813 | } |
| 815 | 814 | |
| 816 | 815 | // Post author IDs for a NOT IN clause. |
| 817 | - if ( ! empty( $this->query_vars['post_author__not_in'] ) ) { |
|
| 816 | + if ( ! empty($this->query_vars['post_author__not_in'])) { |
|
| 818 | 817 | $join_posts_table = true; |
| 819 | - $where[] = 'post_author NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['post_author__not_in'] ) ) . ' )'; |
|
| 818 | + $where[] = 'post_author NOT IN ( '.implode(',', wp_parse_id_list($this->query_vars['post_author__not_in'])).' )'; |
|
| 820 | 819 | } |
| 821 | 820 | |
| 822 | - if ( $join_posts_table ) { |
|
| 821 | + if ($join_posts_table) { |
|
| 823 | 822 | $join = "JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID"; |
| 824 | 823 | } |
| 825 | 824 | |
| 826 | - if ( ! empty( $meta_query_clauses ) ) { |
|
| 825 | + if ( ! empty($meta_query_clauses)) { |
|
| 827 | 826 | $join .= $meta_query_clauses['join']; |
| 828 | 827 | |
| 829 | 828 | // Strip leading 'AND'. |
| 830 | - $where[] = preg_replace( '/^\s*AND\s*/', '', $meta_query_clauses['where'] ); |
|
| 829 | + $where[] = preg_replace('/^\s*AND\s*/', '', $meta_query_clauses['where']); |
|
| 831 | 830 | |
| 832 | - if ( ! $this->query_vars['count'] ) { |
|
| 831 | + if ( ! $this->query_vars['count']) { |
|
| 833 | 832 | $groupby = "{$wpdb->comments}.comment_ID"; |
| 834 | 833 | } |
| 835 | 834 | } |
| 836 | 835 | |
| 837 | 836 | $date_query = $this->query_vars['date_query']; |
| 838 | - if ( ! empty( $date_query ) && is_array( $date_query ) ) { |
|
| 839 | - $date_query_object = new WP_Date_Query( $date_query, 'comment_date' ); |
|
| 840 | - $where[] = preg_replace( '/^\s*AND\s*/', '', $date_query_object->get_sql() ); |
|
| 837 | + if ( ! empty($date_query) && is_array($date_query)) { |
|
| 838 | + $date_query_object = new WP_Date_Query($date_query, 'comment_date'); |
|
| 839 | + $where[] = preg_replace('/^\s*AND\s*/', '', $date_query_object->get_sql()); |
|
| 841 | 840 | } |
| 842 | 841 | |
| 843 | - $where = implode( ' AND ', $where ); |
|
| 842 | + $where = implode(' AND ', $where); |
|
| 844 | 843 | |
| 845 | - $pieces = array( 'fields', 'join', 'where', 'orderby', 'limits', 'groupby' ); |
|
| 844 | + $pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby'); |
|
| 846 | 845 | /** |
| 847 | 846 | * Filter the comment query clauses. |
| 848 | 847 | * |
@@ -851,39 +850,39 @@ discard block |
||
| 851 | 850 | * @param array $pieces A compacted array of comment query clauses. |
| 852 | 851 | * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference. |
| 853 | 852 | */ |
| 854 | - $clauses = apply_filters_ref_array( 'comments_clauses', array( compact( $pieces ), &$this ) ); |
|
| 853 | + $clauses = apply_filters_ref_array('comments_clauses', array(compact($pieces), &$this)); |
|
| 855 | 854 | |
| 856 | - $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; |
|
| 857 | - $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; |
|
| 858 | - $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : ''; |
|
| 859 | - $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : ''; |
|
| 860 | - $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : ''; |
|
| 861 | - $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; |
|
| 855 | + $fields = isset($clauses['fields']) ? $clauses['fields'] : ''; |
|
| 856 | + $join = isset($clauses['join']) ? $clauses['join'] : ''; |
|
| 857 | + $where = isset($clauses['where']) ? $clauses['where'] : ''; |
|
| 858 | + $orderby = isset($clauses['orderby']) ? $clauses['orderby'] : ''; |
|
| 859 | + $limits = isset($clauses['limits']) ? $clauses['limits'] : ''; |
|
| 860 | + $groupby = isset($clauses['groupby']) ? $clauses['groupby'] : ''; |
|
| 862 | 861 | |
| 863 | - if ( $where ) { |
|
| 864 | - $where = 'WHERE ' . $where; |
|
| 862 | + if ($where) { |
|
| 863 | + $where = 'WHERE '.$where; |
|
| 865 | 864 | } |
| 866 | 865 | |
| 867 | - if ( $groupby ) { |
|
| 868 | - $groupby = 'GROUP BY ' . $groupby; |
|
| 866 | + if ($groupby) { |
|
| 867 | + $groupby = 'GROUP BY '.$groupby; |
|
| 869 | 868 | } |
| 870 | 869 | |
| 871 | - if ( $orderby ) { |
|
| 870 | + if ($orderby) { |
|
| 872 | 871 | $orderby = "ORDER BY $orderby"; |
| 873 | 872 | } |
| 874 | 873 | |
| 875 | 874 | $this->request = "SELECT $fields FROM $wpdb->comments $join $where $groupby $orderby $limits"; |
| 876 | 875 | |
| 877 | - if ( $this->query_vars['count'] ) { |
|
| 878 | - return $wpdb->get_var( $this->request ); |
|
| 876 | + if ($this->query_vars['count']) { |
|
| 877 | + return $wpdb->get_var($this->request); |
|
| 879 | 878 | } |
| 880 | 879 | |
| 881 | - if ( 'ids' == $this->query_vars['fields'] ) { |
|
| 882 | - $this->comments = $wpdb->get_col( $this->request ); |
|
| 883 | - return array_map( 'intval', $this->comments ); |
|
| 880 | + if ('ids' == $this->query_vars['fields']) { |
|
| 881 | + $this->comments = $wpdb->get_col($this->request); |
|
| 882 | + return array_map('intval', $this->comments); |
|
| 884 | 883 | } |
| 885 | 884 | |
| 886 | - $results = $wpdb->get_results( $this->request ); |
|
| 885 | + $results = $wpdb->get_results($this->request); |
|
| 887 | 886 | /** |
| 888 | 887 | * Filter the comment query results. |
| 889 | 888 | * |
@@ -892,11 +891,11 @@ discard block |
||
| 892 | 891 | * @param array $results An array of comments. |
| 893 | 892 | * @param WP_Comment_Query &$this Current instance of WP_Comment_Query, passed by reference. |
| 894 | 893 | */ |
| 895 | - $comments = apply_filters_ref_array( 'the_comments', array( $results, &$this ) ); |
|
| 894 | + $comments = apply_filters_ref_array('the_comments', array($results, &$this)); |
|
| 896 | 895 | |
| 897 | - wp_cache_add( $cache_key, $comments, 'comment' ); |
|
| 898 | - if ( '*' === $fields ) { |
|
| 899 | - update_comment_cache( $comments ); |
|
| 896 | + wp_cache_add($cache_key, $comments, 'comment'); |
|
| 897 | + if ('*' === $fields) { |
|
| 898 | + update_comment_cache($comments); |
|
| 900 | 899 | } |
| 901 | 900 | |
| 902 | 901 | $this->comments = $comments; |
@@ -915,17 +914,17 @@ discard block |
||
| 915 | 914 | * @param array $cols |
| 916 | 915 | * @return string |
| 917 | 916 | */ |
| 918 | - protected function get_search_sql( $string, $cols ) { |
|
| 917 | + protected function get_search_sql($string, $cols) { |
|
| 919 | 918 | global $wpdb; |
| 920 | 919 | |
| 921 | - $like = '%' . $wpdb->esc_like( $string ) . '%'; |
|
| 920 | + $like = '%'.$wpdb->esc_like($string).'%'; |
|
| 922 | 921 | |
| 923 | 922 | $searches = array(); |
| 924 | - foreach ( $cols as $col ) { |
|
| 925 | - $searches[] = $wpdb->prepare( "$col LIKE %s", $like ); |
|
| 923 | + foreach ($cols as $col) { |
|
| 924 | + $searches[] = $wpdb->prepare("$col LIKE %s", $like); |
|
| 926 | 925 | } |
| 927 | 926 | |
| 928 | - return ' AND (' . implode(' OR ', $searches) . ')'; |
|
| 927 | + return ' AND ('.implode(' OR ', $searches).')'; |
|
| 929 | 928 | } |
| 930 | 929 | |
| 931 | 930 | /** |
@@ -939,7 +938,7 @@ discard block |
||
| 939 | 938 | * @param string $orderby Alias for the field to order by. |
| 940 | 939 | * @return string|false Value to used in the ORDER clause. False otherwise. |
| 941 | 940 | */ |
| 942 | - protected function parse_orderby( $orderby ) { |
|
| 941 | + protected function parse_orderby($orderby) { |
|
| 943 | 942 | global $wpdb; |
| 944 | 943 | |
| 945 | 944 | $allowed_keys = array( |
@@ -960,27 +959,27 @@ discard block |
||
| 960 | 959 | 'user_id', |
| 961 | 960 | ); |
| 962 | 961 | |
| 963 | - if ( ! empty( $this->query_vars['meta_key'] ) ) { |
|
| 962 | + if ( ! empty($this->query_vars['meta_key'])) { |
|
| 964 | 963 | $allowed_keys[] = $this->query_vars['meta_key']; |
| 965 | 964 | $allowed_keys[] = 'meta_value'; |
| 966 | 965 | $allowed_keys[] = 'meta_value_num'; |
| 967 | 966 | } |
| 968 | 967 | |
| 969 | 968 | $meta_query_clauses = $this->meta_query->get_clauses(); |
| 970 | - if ( $meta_query_clauses ) { |
|
| 971 | - $allowed_keys = array_merge( $allowed_keys, array_keys( $meta_query_clauses ) ); |
|
| 969 | + if ($meta_query_clauses) { |
|
| 970 | + $allowed_keys = array_merge($allowed_keys, array_keys($meta_query_clauses)); |
|
| 972 | 971 | } |
| 973 | 972 | |
| 974 | 973 | $parsed = false; |
| 975 | - if ( $orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value' ) { |
|
| 974 | + if ($orderby == $this->query_vars['meta_key'] || $orderby == 'meta_value') { |
|
| 976 | 975 | $parsed = "$wpdb->commentmeta.meta_value"; |
| 977 | - } elseif ( $orderby == 'meta_value_num' ) { |
|
| 976 | + } elseif ($orderby == 'meta_value_num') { |
|
| 978 | 977 | $parsed = "$wpdb->commentmeta.meta_value+0"; |
| 979 | - } elseif ( in_array( $orderby, $allowed_keys ) ) { |
|
| 978 | + } elseif (in_array($orderby, $allowed_keys)) { |
|
| 980 | 979 | |
| 981 | - if ( isset( $meta_query_clauses[ $orderby ] ) ) { |
|
| 982 | - $meta_clause = $meta_query_clauses[ $orderby ]; |
|
| 983 | - $parsed = sprintf( "CAST(%s.meta_value AS %s)", esc_sql( $meta_clause['alias'] ), esc_sql( $meta_clause['cast'] ) ); |
|
| 980 | + if (isset($meta_query_clauses[$orderby])) { |
|
| 981 | + $meta_clause = $meta_query_clauses[$orderby]; |
|
| 982 | + $parsed = sprintf("CAST(%s.meta_value AS %s)", esc_sql($meta_clause['alias']), esc_sql($meta_clause['cast'])); |
|
| 984 | 983 | } else { |
| 985 | 984 | $parsed = "$wpdb->comments.$orderby"; |
| 986 | 985 | } |
@@ -998,12 +997,12 @@ discard block |
||
| 998 | 997 | * @param string $order The 'order' query variable. |
| 999 | 998 | * @return string The sanitized 'order' query variable. |
| 1000 | 999 | */ |
| 1001 | - protected function parse_order( $order ) { |
|
| 1002 | - if ( ! is_string( $order ) || empty( $order ) ) { |
|
| 1000 | + protected function parse_order($order) { |
|
| 1001 | + if ( ! is_string($order) || empty($order)) { |
|
| 1003 | 1002 | return 'DESC'; |
| 1004 | 1003 | } |
| 1005 | 1004 | |
| 1006 | - if ( 'ASC' === strtoupper( $order ) ) { |
|
| 1005 | + if ('ASC' === strtoupper($order)) { |
|
| 1007 | 1006 | return 'ASC'; |
| 1008 | 1007 | } else { |
| 1009 | 1008 | return 'DESC'; |
@@ -1042,8 +1041,8 @@ discard block |
||
| 1042 | 1041 | * @param string $comment_type Optional. Comment type. Default 'comment'. |
| 1043 | 1042 | * @return string Expected return value is 'open' or 'closed'. |
| 1044 | 1043 | */ |
| 1045 | -function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) { |
|
| 1046 | - switch ( $comment_type ) { |
|
| 1044 | +function get_default_comment_status($post_type = 'post', $comment_type = 'comment') { |
|
| 1045 | + switch ($comment_type) { |
|
| 1047 | 1046 | case 'pingback' : |
| 1048 | 1047 | case 'trackback' : |
| 1049 | 1048 | $supports = 'trackbacks'; |
@@ -1055,10 +1054,10 @@ discard block |
||
| 1055 | 1054 | } |
| 1056 | 1055 | |
| 1057 | 1056 | // Set the status. |
| 1058 | - if ( 'page' === $post_type ) { |
|
| 1057 | + if ('page' === $post_type) { |
|
| 1059 | 1058 | $status = 'closed'; |
| 1060 | - } elseif ( post_type_supports( $post_type, $supports ) ) { |
|
| 1061 | - $status = get_option( "default_{$option}_status" ); |
|
| 1059 | + } elseif (post_type_supports($post_type, $supports)) { |
|
| 1060 | + $status = get_option("default_{$option}_status"); |
|
| 1062 | 1061 | } else { |
| 1063 | 1062 | $status = 'closed'; |
| 1064 | 1063 | } |
@@ -1073,7 +1072,7 @@ discard block |
||
| 1073 | 1072 | * @param string $post_type Post type. Default is `post`. |
| 1074 | 1073 | * @param string $comment_type Type of comment. Default is `comment`. |
| 1075 | 1074 | */ |
| 1076 | - return apply_filters( 'get_default_comment_status' , $status, $post_type, $comment_type ); |
|
| 1075 | + return apply_filters('get_default_comment_status', $status, $post_type, $comment_type); |
|
| 1077 | 1076 | } |
| 1078 | 1077 | |
| 1079 | 1078 | /** |
@@ -1092,12 +1091,12 @@ discard block |
||
| 1092 | 1091 | global $wpdb; |
| 1093 | 1092 | static $cache_lastcommentmodified = array(); |
| 1094 | 1093 | |
| 1095 | - if ( isset($cache_lastcommentmodified[$timezone]) ) |
|
| 1094 | + if (isset($cache_lastcommentmodified[$timezone])) |
|
| 1096 | 1095 | return $cache_lastcommentmodified[$timezone]; |
| 1097 | 1096 | |
| 1098 | 1097 | $add_seconds_server = date('Z'); |
| 1099 | 1098 | |
| 1100 | - switch ( strtolower($timezone)) { |
|
| 1099 | + switch (strtolower($timezone)) { |
|
| 1101 | 1100 | case 'gmt': |
| 1102 | 1101 | $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1"); |
| 1103 | 1102 | break; |
@@ -1128,13 +1127,13 @@ discard block |
||
| 1128 | 1127 | * @param int $post_id Optional. Comment amount in post if > 0, else total comments blog wide. |
| 1129 | 1128 | * @return array The amount of spam, approved, awaiting moderation, and total comments. |
| 1130 | 1129 | */ |
| 1131 | -function get_comment_count( $post_id = 0 ) { |
|
| 1130 | +function get_comment_count($post_id = 0) { |
|
| 1132 | 1131 | global $wpdb; |
| 1133 | 1132 | |
| 1134 | 1133 | $post_id = (int) $post_id; |
| 1135 | 1134 | |
| 1136 | 1135 | $where = ''; |
| 1137 | - if ( $post_id > 0 ) { |
|
| 1136 | + if ($post_id > 0) { |
|
| 1138 | 1137 | $where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id); |
| 1139 | 1138 | } |
| 1140 | 1139 | |
@@ -1152,8 +1151,8 @@ discard block |
||
| 1152 | 1151 | "total_comments" => 0 |
| 1153 | 1152 | ); |
| 1154 | 1153 | |
| 1155 | - foreach ( $totals as $row ) { |
|
| 1156 | - switch ( $row['comment_approved'] ) { |
|
| 1154 | + foreach ($totals as $row) { |
|
| 1155 | + switch ($row['comment_approved']) { |
|
| 1157 | 1156 | case 'spam': |
| 1158 | 1157 | $comment_count['spam'] = $row['total']; |
| 1159 | 1158 | $comment_count["total_comments"] += $row['total']; |
@@ -1260,7 +1259,7 @@ discard block |
||
| 1260 | 1259 | * @since 3.4.0 |
| 1261 | 1260 | */ |
| 1262 | 1261 | function wp_set_comment_cookies($comment, $user) { |
| 1263 | - if ( $user->exists() ) |
|
| 1262 | + if ($user->exists()) |
|
| 1264 | 1263 | return; |
| 1265 | 1264 | |
| 1266 | 1265 | /** |
@@ -1270,11 +1269,11 @@ discard block |
||
| 1270 | 1269 | * |
| 1271 | 1270 | * @param int $seconds Comment cookie lifetime. Default 30000000. |
| 1272 | 1271 | */ |
| 1273 | - $comment_cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 ); |
|
| 1274 | - $secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) ); |
|
| 1275 | - setcookie( 'comment_author_' . COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 1276 | - setcookie( 'comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 1277 | - setcookie( 'comment_author_url_' . COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure ); |
|
| 1272 | + $comment_cookie_lifetime = apply_filters('comment_cookie_lifetime', 30000000); |
|
| 1273 | + $secure = ('https' === parse_url(home_url(), PHP_URL_SCHEME)); |
|
| 1274 | + setcookie('comment_author_'.COOKIEHASH, $comment->comment_author, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 1275 | + setcookie('comment_author_email_'.COOKIEHASH, $comment->comment_author_email, time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 1276 | + setcookie('comment_author_url_'.COOKIEHASH, esc_url($comment->comment_author_url), time() + $comment_cookie_lifetime, COOKIEPATH, COOKIE_DOMAIN, $secure); |
|
| 1278 | 1277 | } |
| 1279 | 1278 | |
| 1280 | 1279 | /** |
@@ -1286,7 +1285,7 @@ discard block |
||
| 1286 | 1285 | * @since 2.0.4 |
| 1287 | 1286 | */ |
| 1288 | 1287 | function sanitize_comment_cookies() { |
| 1289 | - if ( isset( $_COOKIE['comment_author_' . COOKIEHASH] ) ) { |
|
| 1288 | + if (isset($_COOKIE['comment_author_'.COOKIEHASH])) { |
|
| 1290 | 1289 | /** |
| 1291 | 1290 | * Filter the comment author's name cookie before it is set. |
| 1292 | 1291 | * |
@@ -1297,13 +1296,13 @@ discard block |
||
| 1297 | 1296 | * |
| 1298 | 1297 | * @param string $author_cookie The comment author name cookie. |
| 1299 | 1298 | */ |
| 1300 | - $comment_author = apply_filters( 'pre_comment_author_name', $_COOKIE['comment_author_' . COOKIEHASH] ); |
|
| 1299 | + $comment_author = apply_filters('pre_comment_author_name', $_COOKIE['comment_author_'.COOKIEHASH]); |
|
| 1301 | 1300 | $comment_author = wp_unslash($comment_author); |
| 1302 | 1301 | $comment_author = esc_attr($comment_author); |
| 1303 | - $_COOKIE['comment_author_' . COOKIEHASH] = $comment_author; |
|
| 1302 | + $_COOKIE['comment_author_'.COOKIEHASH] = $comment_author; |
|
| 1304 | 1303 | } |
| 1305 | 1304 | |
| 1306 | - if ( isset( $_COOKIE['comment_author_email_' . COOKIEHASH] ) ) { |
|
| 1305 | + if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) { |
|
| 1307 | 1306 | /** |
| 1308 | 1307 | * Filter the comment author's email cookie before it is set. |
| 1309 | 1308 | * |
@@ -1314,13 +1313,13 @@ discard block |
||
| 1314 | 1313 | * |
| 1315 | 1314 | * @param string $author_email_cookie The comment author email cookie. |
| 1316 | 1315 | */ |
| 1317 | - $comment_author_email = apply_filters( 'pre_comment_author_email', $_COOKIE['comment_author_email_' . COOKIEHASH] ); |
|
| 1316 | + $comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]); |
|
| 1318 | 1317 | $comment_author_email = wp_unslash($comment_author_email); |
| 1319 | 1318 | $comment_author_email = esc_attr($comment_author_email); |
| 1320 | 1319 | $_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email; |
| 1321 | 1320 | } |
| 1322 | 1321 | |
| 1323 | - if ( isset( $_COOKIE['comment_author_url_' . COOKIEHASH] ) ) { |
|
| 1322 | + if (isset($_COOKIE['comment_author_url_'.COOKIEHASH])) { |
|
| 1324 | 1323 | /** |
| 1325 | 1324 | * Filter the comment author's URL cookie before it is set. |
| 1326 | 1325 | * |
@@ -1331,7 +1330,7 @@ discard block |
||
| 1331 | 1330 | * |
| 1332 | 1331 | * @param string $author_url_cookie The comment author URL cookie. |
| 1333 | 1332 | */ |
| 1334 | - $comment_author_url = apply_filters( 'pre_comment_author_url', $_COOKIE['comment_author_url_' . COOKIEHASH] ); |
|
| 1333 | + $comment_author_url = apply_filters('pre_comment_author_url', $_COOKIE['comment_author_url_'.COOKIEHASH]); |
|
| 1335 | 1334 | $comment_author_url = wp_unslash($comment_author_url); |
| 1336 | 1335 | $_COOKIE['comment_author_url_'.COOKIEHASH] = $comment_author_url; |
| 1337 | 1336 | } |
@@ -1347,28 +1346,28 @@ discard block |
||
| 1347 | 1346 | * @param array $commentdata Contains information on the comment |
| 1348 | 1347 | * @return int|string Signifies the approval status (0|1|'spam') |
| 1349 | 1348 | */ |
| 1350 | -function wp_allow_comment( $commentdata ) { |
|
| 1349 | +function wp_allow_comment($commentdata) { |
|
| 1351 | 1350 | global $wpdb; |
| 1352 | 1351 | |
| 1353 | 1352 | // Simple duplicate check |
| 1354 | 1353 | // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) |
| 1355 | 1354 | $dupe = $wpdb->prepare( |
| 1356 | 1355 | "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", |
| 1357 | - wp_unslash( $commentdata['comment_post_ID'] ), |
|
| 1358 | - wp_unslash( $commentdata['comment_parent'] ), |
|
| 1359 | - wp_unslash( $commentdata['comment_author'] ) |
|
| 1356 | + wp_unslash($commentdata['comment_post_ID']), |
|
| 1357 | + wp_unslash($commentdata['comment_parent']), |
|
| 1358 | + wp_unslash($commentdata['comment_author']) |
|
| 1360 | 1359 | ); |
| 1361 | - if ( $commentdata['comment_author_email'] ) { |
|
| 1360 | + if ($commentdata['comment_author_email']) { |
|
| 1362 | 1361 | $dupe .= $wpdb->prepare( |
| 1363 | 1362 | "OR comment_author_email = %s ", |
| 1364 | - wp_unslash( $commentdata['comment_author_email'] ) |
|
| 1363 | + wp_unslash($commentdata['comment_author_email']) |
|
| 1365 | 1364 | ); |
| 1366 | 1365 | } |
| 1367 | 1366 | $dupe .= $wpdb->prepare( |
| 1368 | 1367 | ") AND comment_content = %s LIMIT 1", |
| 1369 | - wp_unslash( $commentdata['comment_content'] ) |
|
| 1368 | + wp_unslash($commentdata['comment_content']) |
|
| 1370 | 1369 | ); |
| 1371 | - if ( $wpdb->get_var( $dupe ) ) { |
|
| 1370 | + if ($wpdb->get_var($dupe)) { |
|
| 1372 | 1371 | /** |
| 1373 | 1372 | * Fires immediately after a duplicate comment is detected. |
| 1374 | 1373 | * |
@@ -1376,11 +1375,11 @@ discard block |
||
| 1376 | 1375 | * |
| 1377 | 1376 | * @param array $commentdata Comment data. |
| 1378 | 1377 | */ |
| 1379 | - do_action( 'comment_duplicate_trigger', $commentdata ); |
|
| 1380 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 1381 | - die( __('Duplicate comment detected; it looks as though you’ve already said that!') ); |
|
| 1378 | + do_action('comment_duplicate_trigger', $commentdata); |
|
| 1379 | + if (defined('DOING_AJAX')) { |
|
| 1380 | + die(__('Duplicate comment detected; it looks as though you’ve already said that!')); |
|
| 1382 | 1381 | } |
| 1383 | - wp_die( __( 'Duplicate comment detected; it looks as though you’ve already said that!' ), 409 ); |
|
| 1382 | + wp_die(__('Duplicate comment detected; it looks as though you’ve already said that!'), 409); |
|
| 1384 | 1383 | } |
| 1385 | 1384 | |
| 1386 | 1385 | /** |
@@ -1401,20 +1400,20 @@ discard block |
||
| 1401 | 1400 | $commentdata['comment_date_gmt'] |
| 1402 | 1401 | ); |
| 1403 | 1402 | |
| 1404 | - if ( ! empty( $commentdata['user_id'] ) ) { |
|
| 1405 | - $user = get_userdata( $commentdata['user_id'] ); |
|
| 1406 | - $post_author = $wpdb->get_var( $wpdb->prepare( |
|
| 1403 | + if ( ! empty($commentdata['user_id'])) { |
|
| 1404 | + $user = get_userdata($commentdata['user_id']); |
|
| 1405 | + $post_author = $wpdb->get_var($wpdb->prepare( |
|
| 1407 | 1406 | "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", |
| 1408 | 1407 | $commentdata['comment_post_ID'] |
| 1409 | - ) ); |
|
| 1408 | + )); |
|
| 1410 | 1409 | } |
| 1411 | 1410 | |
| 1412 | - if ( isset( $user ) && ( $commentdata['user_id'] == $post_author || $user->has_cap( 'moderate_comments' ) ) ) { |
|
| 1411 | + if (isset($user) && ($commentdata['user_id'] == $post_author || $user->has_cap('moderate_comments'))) { |
|
| 1413 | 1412 | // The author and the admins get respect. |
| 1414 | 1413 | $approved = 1; |
| 1415 | 1414 | } else { |
| 1416 | 1415 | // Everyone else's comments will be checked. |
| 1417 | - if ( check_comment( |
|
| 1416 | + if (check_comment( |
|
| 1418 | 1417 | $commentdata['comment_author'], |
| 1419 | 1418 | $commentdata['comment_author_email'], |
| 1420 | 1419 | $commentdata['comment_author_url'], |
@@ -1422,20 +1421,20 @@ discard block |
||
| 1422 | 1421 | $commentdata['comment_author_IP'], |
| 1423 | 1422 | $commentdata['comment_agent'], |
| 1424 | 1423 | $commentdata['comment_type'] |
| 1425 | - ) ) { |
|
| 1424 | + )) { |
|
| 1426 | 1425 | $approved = 1; |
| 1427 | 1426 | } else { |
| 1428 | 1427 | $approved = 0; |
| 1429 | 1428 | } |
| 1430 | 1429 | |
| 1431 | - if ( wp_blacklist_check( |
|
| 1430 | + if (wp_blacklist_check( |
|
| 1432 | 1431 | $commentdata['comment_author'], |
| 1433 | 1432 | $commentdata['comment_author_email'], |
| 1434 | 1433 | $commentdata['comment_author_url'], |
| 1435 | 1434 | $commentdata['comment_content'], |
| 1436 | 1435 | $commentdata['comment_author_IP'], |
| 1437 | 1436 | $commentdata['comment_agent'] |
| 1438 | - ) ) { |
|
| 1437 | + )) { |
|
| 1439 | 1438 | $approved = 'spam'; |
| 1440 | 1439 | } |
| 1441 | 1440 | } |
@@ -1448,7 +1447,7 @@ discard block |
||
| 1448 | 1447 | * @param bool|string $approved The approval status. Accepts 1, 0, or 'spam'. |
| 1449 | 1448 | * @param array $commentdata Comment data. |
| 1450 | 1449 | */ |
| 1451 | - $approved = apply_filters( 'pre_comment_approved', $approved, $commentdata ); |
|
| 1450 | + $approved = apply_filters('pre_comment_approved', $approved, $commentdata); |
|
| 1452 | 1451 | return $approved; |
| 1453 | 1452 | } |
| 1454 | 1453 | |
@@ -1466,12 +1465,12 @@ discard block |
||
| 1466 | 1465 | * @param string $email Comment author email address. |
| 1467 | 1466 | * @param string $date MySQL time string. |
| 1468 | 1467 | */ |
| 1469 | -function check_comment_flood_db( $ip, $email, $date ) { |
|
| 1468 | +function check_comment_flood_db($ip, $email, $date) { |
|
| 1470 | 1469 | global $wpdb; |
| 1471 | - if ( current_user_can( 'manage_options' ) ) |
|
| 1470 | + if (current_user_can('manage_options')) |
|
| 1472 | 1471 | return; // don't throttle admins |
| 1473 | - $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); |
|
| 1474 | - if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) { |
|
| 1472 | + $hour_ago = gmdate('Y-m-d H:i:s', time() - HOUR_IN_SECONDS); |
|
| 1473 | + if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email))) { |
|
| 1475 | 1474 | $time_lastcomment = mysql2date('U', $lasttime, false); |
| 1476 | 1475 | $time_newcomment = mysql2date('U', $date, false); |
| 1477 | 1476 | /** |
@@ -1483,8 +1482,8 @@ discard block |
||
| 1483 | 1482 | * @param int $time_lastcomment Timestamp of when the last comment was posted. |
| 1484 | 1483 | * @param int $time_newcomment Timestamp of when the new comment was posted. |
| 1485 | 1484 | */ |
| 1486 | - $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); |
|
| 1487 | - if ( $flood_die ) { |
|
| 1485 | + $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); |
|
| 1486 | + if ($flood_die) { |
|
| 1488 | 1487 | /** |
| 1489 | 1488 | * Fires before the comment flood message is triggered. |
| 1490 | 1489 | * |
@@ -1493,12 +1492,12 @@ discard block |
||
| 1493 | 1492 | * @param int $time_lastcomment Timestamp of when the last comment was posted. |
| 1494 | 1493 | * @param int $time_newcomment Timestamp of when the new comment was posted. |
| 1495 | 1494 | */ |
| 1496 | - do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); |
|
| 1495 | + do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment); |
|
| 1497 | 1496 | |
| 1498 | - if ( defined('DOING_AJAX') ) |
|
| 1499 | - die( __('You are posting comments too quickly. Slow down.') ); |
|
| 1497 | + if (defined('DOING_AJAX')) |
|
| 1498 | + die(__('You are posting comments too quickly. Slow down.')); |
|
| 1500 | 1499 | |
| 1501 | - wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); |
|
| 1500 | + wp_die(__('You are posting comments too quickly. Slow down.'), 429); |
|
| 1502 | 1501 | } |
| 1503 | 1502 | } |
| 1504 | 1503 | } |
@@ -1514,12 +1513,12 @@ discard block |
||
| 1514 | 1513 | function separate_comments(&$comments) { |
| 1515 | 1514 | $comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array()); |
| 1516 | 1515 | $count = count($comments); |
| 1517 | - for ( $i = 0; $i < $count; $i++ ) { |
|
| 1516 | + for ($i = 0; $i < $count; $i++) { |
|
| 1518 | 1517 | $type = $comments[$i]->comment_type; |
| 1519 | - if ( empty($type) ) |
|
| 1518 | + if (empty($type)) |
|
| 1520 | 1519 | $type = 'comment'; |
| 1521 | 1520 | $comments_by_type[$type][] = &$comments[$i]; |
| 1522 | - if ( 'trackback' == $type || 'pingback' == $type ) |
|
| 1521 | + if ('trackback' == $type || 'pingback' == $type) |
|
| 1523 | 1522 | $comments_by_type['pings'][] = &$comments[$i]; |
| 1524 | 1523 | } |
| 1525 | 1524 | |
@@ -1540,36 +1539,36 @@ discard block |
||
| 1540 | 1539 | * @param bool $threaded Optional control over flat or threaded comments. |
| 1541 | 1540 | * @return int Number of comment pages. |
| 1542 | 1541 | */ |
| 1543 | -function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { |
|
| 1542 | +function get_comment_pages_count($comments = null, $per_page = null, $threaded = null) { |
|
| 1544 | 1543 | global $wp_query; |
| 1545 | 1544 | |
| 1546 | - if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) |
|
| 1545 | + if (null === $comments && null === $per_page && null === $threaded && ! empty($wp_query->max_num_comment_pages)) |
|
| 1547 | 1546 | return $wp_query->max_num_comment_pages; |
| 1548 | 1547 | |
| 1549 | - if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) |
|
| 1548 | + if (( ! $comments || ! is_array($comments)) && ! empty($wp_query->comments)) |
|
| 1550 | 1549 | $comments = $wp_query->comments; |
| 1551 | 1550 | |
| 1552 | - if ( empty($comments) ) |
|
| 1551 | + if (empty($comments)) |
|
| 1553 | 1552 | return 0; |
| 1554 | 1553 | |
| 1555 | - if ( ! get_option( 'page_comments' ) ) |
|
| 1554 | + if ( ! get_option('page_comments')) |
|
| 1556 | 1555 | return 1; |
| 1557 | 1556 | |
| 1558 | - if ( !isset($per_page) ) |
|
| 1557 | + if ( ! isset($per_page)) |
|
| 1559 | 1558 | $per_page = (int) get_query_var('comments_per_page'); |
| 1560 | - if ( 0 === $per_page ) |
|
| 1559 | + if (0 === $per_page) |
|
| 1561 | 1560 | $per_page = (int) get_option('comments_per_page'); |
| 1562 | - if ( 0 === $per_page ) |
|
| 1561 | + if (0 === $per_page) |
|
| 1563 | 1562 | return 1; |
| 1564 | 1563 | |
| 1565 | - if ( !isset($threaded) ) |
|
| 1564 | + if ( ! isset($threaded)) |
|
| 1566 | 1565 | $threaded = get_option('thread_comments'); |
| 1567 | 1566 | |
| 1568 | - if ( $threaded ) { |
|
| 1567 | + if ($threaded) { |
|
| 1569 | 1568 | $walker = new Walker_Comment; |
| 1570 | - $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page ); |
|
| 1569 | + $count = ceil($walker->get_number_of_root_elements($comments) / $per_page); |
|
| 1571 | 1570 | } else { |
| 1572 | - $count = ceil( count( $comments ) / $per_page ); |
|
| 1571 | + $count = ceil(count($comments) / $per_page); |
|
| 1573 | 1572 | } |
| 1574 | 1573 | |
| 1575 | 1574 | return $count; |
@@ -1586,34 +1585,34 @@ discard block |
||
| 1586 | 1585 | * @param array $args Optional args. |
| 1587 | 1586 | * @return int|null Comment page number or null on error. |
| 1588 | 1587 | */ |
| 1589 | -function get_page_of_comment( $comment_ID, $args = array() ) { |
|
| 1588 | +function get_page_of_comment($comment_ID, $args = array()) { |
|
| 1590 | 1589 | global $wpdb; |
| 1591 | 1590 | |
| 1592 | - if ( !$comment = get_comment( $comment_ID ) ) |
|
| 1591 | + if ( ! $comment = get_comment($comment_ID)) |
|
| 1593 | 1592 | return; |
| 1594 | 1593 | |
| 1595 | - $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
|
| 1596 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1594 | + $defaults = array('type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => ''); |
|
| 1595 | + $args = wp_parse_args($args, $defaults); |
|
| 1597 | 1596 | |
| 1598 | - if ( '' === $args['per_page'] && get_option('page_comments') ) |
|
| 1597 | + if ('' === $args['per_page'] && get_option('page_comments')) |
|
| 1599 | 1598 | $args['per_page'] = get_query_var('comments_per_page'); |
| 1600 | - if ( empty($args['per_page']) ) { |
|
| 1599 | + if (empty($args['per_page'])) { |
|
| 1601 | 1600 | $args['per_page'] = 0; |
| 1602 | 1601 | $args['page'] = 0; |
| 1603 | 1602 | } |
| 1604 | - if ( $args['per_page'] < 1 ) |
|
| 1603 | + if ($args['per_page'] < 1) |
|
| 1605 | 1604 | return 1; |
| 1606 | 1605 | |
| 1607 | - if ( '' === $args['max_depth'] ) { |
|
| 1608 | - if ( get_option('thread_comments') ) |
|
| 1606 | + if ('' === $args['max_depth']) { |
|
| 1607 | + if (get_option('thread_comments')) |
|
| 1609 | 1608 | $args['max_depth'] = get_option('thread_comments_depth'); |
| 1610 | 1609 | else |
| 1611 | 1610 | $args['max_depth'] = -1; |
| 1612 | 1611 | } |
| 1613 | 1612 | |
| 1614 | 1613 | // Find this comment's top level parent if threading is enabled |
| 1615 | - if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) |
|
| 1616 | - return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 1614 | + if ($args['max_depth'] > 1 && 0 != $comment->comment_parent) |
|
| 1615 | + return get_page_of_comment($comment->comment_parent, $args); |
|
| 1617 | 1616 | |
| 1618 | 1617 | $allowedtypes = array( |
| 1619 | 1618 | 'comment' => '', |
@@ -1621,17 +1620,17 @@ discard block |
||
| 1621 | 1620 | 'trackback' => 'trackback', |
| 1622 | 1621 | ); |
| 1623 | 1622 | |
| 1624 | - $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : ''; |
|
| 1623 | + $comtypewhere = ('all' != $args['type'] && isset($allowedtypes[$args['type']])) ? " AND comment_type = '".$allowedtypes[$args['type']]."'" : ''; |
|
| 1625 | 1624 | |
| 1626 | 1625 | // Count comments older than this one |
| 1627 | - $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); |
|
| 1626 | + $oldercoms = $wpdb->get_var($wpdb->prepare("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'".$comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt)); |
|
| 1628 | 1627 | |
| 1629 | 1628 | // No older comments? Then it's page #1. |
| 1630 | - if ( 0 == $oldercoms ) |
|
| 1629 | + if (0 == $oldercoms) |
|
| 1631 | 1630 | return 1; |
| 1632 | 1631 | |
| 1633 | 1632 | // Divide comments older than this one by comments per page to get this comment's page number |
| 1634 | - return ceil( ( $oldercoms + 1 ) / $args['per_page'] ); |
|
| 1633 | + return ceil(($oldercoms + 1) / $args['per_page']); |
|
| 1635 | 1634 | } |
| 1636 | 1635 | |
| 1637 | 1636 | /** |
@@ -1660,18 +1659,18 @@ discard block |
||
| 1660 | 1659 | * @param string $user_ip Comment author's IP address. |
| 1661 | 1660 | * @param string $user_agent Comment author's browser user agent. |
| 1662 | 1661 | */ |
| 1663 | - do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); |
|
| 1662 | + do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); |
|
| 1664 | 1663 | |
| 1665 | - $mod_keys = trim( get_option('blacklist_keys') ); |
|
| 1666 | - if ( '' == $mod_keys ) |
|
| 1664 | + $mod_keys = trim(get_option('blacklist_keys')); |
|
| 1665 | + if ('' == $mod_keys) |
|
| 1667 | 1666 | return false; // If moderation keys are empty |
| 1668 | - $words = explode("\n", $mod_keys ); |
|
| 1667 | + $words = explode("\n", $mod_keys); |
|
| 1669 | 1668 | |
| 1670 | - foreach ( (array) $words as $word ) { |
|
| 1669 | + foreach ((array) $words as $word) { |
|
| 1671 | 1670 | $word = trim($word); |
| 1672 | 1671 | |
| 1673 | 1672 | // Skip empty lines |
| 1674 | - if ( empty($word) ) { continue; } |
|
| 1673 | + if (empty($word)) { continue; } |
|
| 1675 | 1674 | |
| 1676 | 1675 | // Do some escaping magic so that '#' chars in the |
| 1677 | 1676 | // spam words don't break things: |
@@ -1709,7 +1708,7 @@ discard block |
||
| 1709 | 1708 | * @param int $post_id Optional. Post ID. |
| 1710 | 1709 | * @return object|array Comment stats. |
| 1711 | 1710 | */ |
| 1712 | -function wp_count_comments( $post_id = 0 ) { |
|
| 1711 | +function wp_count_comments($post_id = 0) { |
|
| 1713 | 1712 | global $wpdb; |
| 1714 | 1713 | |
| 1715 | 1714 | $post_id = (int) $post_id; |
@@ -1722,34 +1721,34 @@ discard block |
||
| 1722 | 1721 | * @param array $count An empty array. |
| 1723 | 1722 | * @param int $post_id The post ID. |
| 1724 | 1723 | */ |
| 1725 | - $stats = apply_filters( 'wp_count_comments', array(), $post_id ); |
|
| 1726 | - if ( !empty($stats) ) |
|
| 1724 | + $stats = apply_filters('wp_count_comments', array(), $post_id); |
|
| 1725 | + if ( ! empty($stats)) |
|
| 1727 | 1726 | return $stats; |
| 1728 | 1727 | |
| 1729 | 1728 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
| 1730 | 1729 | |
| 1731 | - if ( false !== $count ) |
|
| 1730 | + if (false !== $count) |
|
| 1732 | 1731 | return $count; |
| 1733 | 1732 | |
| 1734 | 1733 | $where = ''; |
| 1735 | - if ( $post_id > 0 ) |
|
| 1736 | - $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id ); |
|
| 1734 | + if ($post_id > 0) |
|
| 1735 | + $where = $wpdb->prepare("WHERE comment_post_ID = %d", $post_id); |
|
| 1737 | 1736 | |
| 1738 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 1737 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 1739 | 1738 | |
| 1740 | 1739 | $total = 0; |
| 1741 | 1740 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
| 1742 | - foreach ( (array) $count as $row ) { |
|
| 1741 | + foreach ((array) $count as $row) { |
|
| 1743 | 1742 | // Don't count post-trashed toward totals |
| 1744 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
| 1743 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
| 1745 | 1744 | $total += $row['num_comments']; |
| 1746 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
| 1745 | + if (isset($approved[$row['comment_approved']])) |
|
| 1747 | 1746 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
| 1748 | 1747 | } |
| 1749 | 1748 | |
| 1750 | 1749 | $stats['total_comments'] = $total; |
| 1751 | - foreach ( $approved as $key ) { |
|
| 1752 | - if ( empty($stats[$key]) ) |
|
| 1750 | + foreach ($approved as $key) { |
|
| 1751 | + if (empty($stats[$key])) |
|
| 1753 | 1752 | $stats[$key] = 0; |
| 1754 | 1753 | } |
| 1755 | 1754 | |
@@ -1778,10 +1777,10 @@ discard block |
||
| 1778 | 1777 | */ |
| 1779 | 1778 | function wp_delete_comment($comment_id, $force_delete = false) { |
| 1780 | 1779 | global $wpdb; |
| 1781 | - if (!$comment = get_comment($comment_id)) |
|
| 1780 | + if ( ! $comment = get_comment($comment_id)) |
|
| 1782 | 1781 | return false; |
| 1783 | 1782 | |
| 1784 | - if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) ) |
|
| 1783 | + if ( ! $force_delete && EMPTY_TRASH_DAYS && ! in_array(wp_get_comment_status($comment_id), array('trash', 'spam'))) |
|
| 1785 | 1784 | return wp_trash_comment($comment_id); |
| 1786 | 1785 | |
| 1787 | 1786 | /** |
@@ -1791,21 +1790,21 @@ discard block |
||
| 1791 | 1790 | * |
| 1792 | 1791 | * @param int $comment_id The comment ID. |
| 1793 | 1792 | */ |
| 1794 | - do_action( 'delete_comment', $comment_id ); |
|
| 1793 | + do_action('delete_comment', $comment_id); |
|
| 1795 | 1794 | |
| 1796 | 1795 | // Move children up a level. |
| 1797 | - $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) ); |
|
| 1798 | - if ( !empty($children) ) { |
|
| 1796 | + $children = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id)); |
|
| 1797 | + if ( ! empty($children)) { |
|
| 1799 | 1798 | $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id)); |
| 1800 | 1799 | clean_comment_cache($children); |
| 1801 | 1800 | } |
| 1802 | 1801 | |
| 1803 | 1802 | // Delete metadata |
| 1804 | - $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment_id ) ); |
|
| 1805 | - foreach ( $meta_ids as $mid ) |
|
| 1806 | - delete_metadata_by_mid( 'comment', $mid ); |
|
| 1803 | + $meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment_id)); |
|
| 1804 | + foreach ($meta_ids as $mid) |
|
| 1805 | + delete_metadata_by_mid('comment', $mid); |
|
| 1807 | 1806 | |
| 1808 | - if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) |
|
| 1807 | + if ( ! $wpdb->delete($wpdb->comments, array('comment_ID' => $comment_id))) |
|
| 1809 | 1808 | return false; |
| 1810 | 1809 | |
| 1811 | 1810 | /** |
@@ -1815,16 +1814,16 @@ discard block |
||
| 1815 | 1814 | * |
| 1816 | 1815 | * @param int $comment_id The comment ID. |
| 1817 | 1816 | */ |
| 1818 | - do_action( 'deleted_comment', $comment_id ); |
|
| 1817 | + do_action('deleted_comment', $comment_id); |
|
| 1819 | 1818 | |
| 1820 | 1819 | $post_id = $comment->comment_post_ID; |
| 1821 | - if ( $post_id && $comment->comment_approved == 1 ) |
|
| 1820 | + if ($post_id && $comment->comment_approved == 1) |
|
| 1822 | 1821 | wp_update_comment_count($post_id); |
| 1823 | 1822 | |
| 1824 | 1823 | clean_comment_cache($comment_id); |
| 1825 | 1824 | |
| 1826 | 1825 | /** This action is documented in wp-includes/comment.php */ |
| 1827 | - do_action( 'wp_set_comment_status', $comment_id, 'delete' ); |
|
| 1826 | + do_action('wp_set_comment_status', $comment_id, 'delete'); |
|
| 1828 | 1827 | |
| 1829 | 1828 | wp_transition_comment_status('delete', $comment->comment_approved, $comment); |
| 1830 | 1829 | return true; |
@@ -1841,10 +1840,10 @@ discard block |
||
| 1841 | 1840 | * @return bool True on success, false on failure. |
| 1842 | 1841 | */ |
| 1843 | 1842 | function wp_trash_comment($comment_id) { |
| 1844 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 1843 | + if ( ! EMPTY_TRASH_DAYS) |
|
| 1845 | 1844 | return wp_delete_comment($comment_id, true); |
| 1846 | 1845 | |
| 1847 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1846 | + if ( ! $comment = get_comment($comment_id)) |
|
| 1848 | 1847 | return false; |
| 1849 | 1848 | |
| 1850 | 1849 | /** |
@@ -1854,13 +1853,13 @@ discard block |
||
| 1854 | 1853 | * |
| 1855 | 1854 | * @param int $comment_id The comment ID. |
| 1856 | 1855 | */ |
| 1857 | - do_action( 'trash_comment', $comment_id ); |
|
| 1856 | + do_action('trash_comment', $comment_id); |
|
| 1858 | 1857 | |
| 1859 | - if ( wp_set_comment_status($comment_id, 'trash') ) { |
|
| 1860 | - delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); |
|
| 1861 | - delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); |
|
| 1862 | - add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); |
|
| 1863 | - add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); |
|
| 1858 | + if (wp_set_comment_status($comment_id, 'trash')) { |
|
| 1859 | + delete_comment_meta($comment_id, '_wp_trash_meta_status'); |
|
| 1860 | + delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
|
| 1861 | + add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); |
|
| 1862 | + add_comment_meta($comment_id, '_wp_trash_meta_time', time()); |
|
| 1864 | 1863 | |
| 1865 | 1864 | /** |
| 1866 | 1865 | * Fires immediately after a comment is sent to Trash. |
@@ -1869,7 +1868,7 @@ discard block |
||
| 1869 | 1868 | * |
| 1870 | 1869 | * @param int $comment_id The comment ID. |
| 1871 | 1870 | */ |
| 1872 | - do_action( 'trashed_comment', $comment_id ); |
|
| 1871 | + do_action('trashed_comment', $comment_id); |
|
| 1873 | 1872 | return true; |
| 1874 | 1873 | } |
| 1875 | 1874 | |
@@ -1885,7 +1884,7 @@ discard block |
||
| 1885 | 1884 | * @return bool True on success, false on failure. |
| 1886 | 1885 | */ |
| 1887 | 1886 | function wp_untrash_comment($comment_id) { |
| 1888 | - if ( ! (int)$comment_id ) |
|
| 1887 | + if ( ! (int) $comment_id) |
|
| 1889 | 1888 | return false; |
| 1890 | 1889 | |
| 1891 | 1890 | /** |
@@ -1895,13 +1894,13 @@ discard block |
||
| 1895 | 1894 | * |
| 1896 | 1895 | * @param int $comment_id The comment ID. |
| 1897 | 1896 | */ |
| 1898 | - do_action( 'untrash_comment', $comment_id ); |
|
| 1897 | + do_action('untrash_comment', $comment_id); |
|
| 1899 | 1898 | |
| 1900 | 1899 | $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); |
| 1901 | - if ( empty($status) ) |
|
| 1900 | + if (empty($status)) |
|
| 1902 | 1901 | $status = '0'; |
| 1903 | 1902 | |
| 1904 | - if ( wp_set_comment_status($comment_id, $status) ) { |
|
| 1903 | + if (wp_set_comment_status($comment_id, $status)) { |
|
| 1905 | 1904 | delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
| 1906 | 1905 | delete_comment_meta($comment_id, '_wp_trash_meta_status'); |
| 1907 | 1906 | /** |
@@ -1911,7 +1910,7 @@ discard block |
||
| 1911 | 1910 | * |
| 1912 | 1911 | * @param int $comment_id The comment ID. |
| 1913 | 1912 | */ |
| 1914 | - do_action( 'untrashed_comment', $comment_id ); |
|
| 1913 | + do_action('untrashed_comment', $comment_id); |
|
| 1915 | 1914 | return true; |
| 1916 | 1915 | } |
| 1917 | 1916 | |
@@ -1927,7 +1926,7 @@ discard block |
||
| 1927 | 1926 | * @return bool True on success, false on failure. |
| 1928 | 1927 | */ |
| 1929 | 1928 | function wp_spam_comment($comment_id) { |
| 1930 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1929 | + if ( ! $comment = get_comment($comment_id)) |
|
| 1931 | 1930 | return false; |
| 1932 | 1931 | |
| 1933 | 1932 | /** |
@@ -1937,13 +1936,13 @@ discard block |
||
| 1937 | 1936 | * |
| 1938 | 1937 | * @param int $comment_id The comment ID. |
| 1939 | 1938 | */ |
| 1940 | - do_action( 'spam_comment', $comment_id ); |
|
| 1939 | + do_action('spam_comment', $comment_id); |
|
| 1941 | 1940 | |
| 1942 | - if ( wp_set_comment_status($comment_id, 'spam') ) { |
|
| 1943 | - delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); |
|
| 1944 | - delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); |
|
| 1945 | - add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); |
|
| 1946 | - add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); |
|
| 1941 | + if (wp_set_comment_status($comment_id, 'spam')) { |
|
| 1942 | + delete_comment_meta($comment_id, '_wp_trash_meta_status'); |
|
| 1943 | + delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
|
| 1944 | + add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); |
|
| 1945 | + add_comment_meta($comment_id, '_wp_trash_meta_time', time()); |
|
| 1947 | 1946 | /** |
| 1948 | 1947 | * Fires immediately after a comment is marked as Spam. |
| 1949 | 1948 | * |
@@ -1951,7 +1950,7 @@ discard block |
||
| 1951 | 1950 | * |
| 1952 | 1951 | * @param int $comment_id The comment ID. |
| 1953 | 1952 | */ |
| 1954 | - do_action( 'spammed_comment', $comment_id ); |
|
| 1953 | + do_action('spammed_comment', $comment_id); |
|
| 1955 | 1954 | return true; |
| 1956 | 1955 | } |
| 1957 | 1956 | |
@@ -1967,7 +1966,7 @@ discard block |
||
| 1967 | 1966 | * @return bool True on success, false on failure. |
| 1968 | 1967 | */ |
| 1969 | 1968 | function wp_unspam_comment($comment_id) { |
| 1970 | - if ( ! (int)$comment_id ) |
|
| 1969 | + if ( ! (int) $comment_id) |
|
| 1971 | 1970 | return false; |
| 1972 | 1971 | |
| 1973 | 1972 | /** |
@@ -1977,15 +1976,15 @@ discard block |
||
| 1977 | 1976 | * |
| 1978 | 1977 | * @param int $comment_id The comment ID. |
| 1979 | 1978 | */ |
| 1980 | - do_action( 'unspam_comment', $comment_id ); |
|
| 1979 | + do_action('unspam_comment', $comment_id); |
|
| 1981 | 1980 | |
| 1982 | 1981 | $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); |
| 1983 | - if ( empty($status) ) |
|
| 1982 | + if (empty($status)) |
|
| 1984 | 1983 | $status = '0'; |
| 1985 | 1984 | |
| 1986 | - if ( wp_set_comment_status($comment_id, $status) ) { |
|
| 1987 | - delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); |
|
| 1988 | - delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); |
|
| 1985 | + if (wp_set_comment_status($comment_id, $status)) { |
|
| 1986 | + delete_comment_meta($comment_id, '_wp_trash_meta_status'); |
|
| 1987 | + delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
|
| 1989 | 1988 | /** |
| 1990 | 1989 | * Fires immediately after a comment is unmarked as Spam. |
| 1991 | 1990 | * |
@@ -1993,7 +1992,7 @@ discard block |
||
| 1993 | 1992 | * |
| 1994 | 1993 | * @param int $comment_id The comment ID. |
| 1995 | 1994 | */ |
| 1996 | - do_action( 'unspammed_comment', $comment_id ); |
|
| 1995 | + do_action('unspammed_comment', $comment_id); |
|
| 1997 | 1996 | return true; |
| 1998 | 1997 | } |
| 1999 | 1998 | |
@@ -2010,20 +2009,20 @@ discard block |
||
| 2010 | 2009 | */ |
| 2011 | 2010 | function wp_get_comment_status($comment_id) { |
| 2012 | 2011 | $comment = get_comment($comment_id); |
| 2013 | - if ( !$comment ) |
|
| 2012 | + if ( ! $comment) |
|
| 2014 | 2013 | return false; |
| 2015 | 2014 | |
| 2016 | 2015 | $approved = $comment->comment_approved; |
| 2017 | 2016 | |
| 2018 | - if ( $approved == null ) |
|
| 2017 | + if ($approved == null) |
|
| 2019 | 2018 | return false; |
| 2020 | - elseif ( $approved == '1' ) |
|
| 2019 | + elseif ($approved == '1') |
|
| 2021 | 2020 | return 'approved'; |
| 2022 | - elseif ( $approved == '0' ) |
|
| 2021 | + elseif ($approved == '0') |
|
| 2023 | 2022 | return 'unapproved'; |
| 2024 | - elseif ( $approved == 'spam' ) |
|
| 2023 | + elseif ($approved == 'spam') |
|
| 2025 | 2024 | return 'spam'; |
| 2026 | - elseif ( $approved == 'trash' ) |
|
| 2025 | + elseif ($approved == 'trash') |
|
| 2027 | 2026 | return 'trash'; |
| 2028 | 2027 | else |
| 2029 | 2028 | return false; |
@@ -2061,11 +2060,11 @@ discard block |
||
| 2061 | 2060 | 1 => 'approved', |
| 2062 | 2061 | 'approve' => 'approved', // wp_set_comment_status() uses "approve" |
| 2063 | 2062 | ); |
| 2064 | - if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; |
|
| 2065 | - if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; |
|
| 2063 | + if (isset($comment_statuses[$new_status])) $new_status = $comment_statuses[$new_status]; |
|
| 2064 | + if (isset($comment_statuses[$old_status])) $old_status = $comment_statuses[$old_status]; |
|
| 2066 | 2065 | |
| 2067 | 2066 | // Call the hooks |
| 2068 | - if ( $new_status != $old_status ) { |
|
| 2067 | + if ($new_status != $old_status) { |
|
| 2069 | 2068 | /** |
| 2070 | 2069 | * Fires when the comment status is in transition. |
| 2071 | 2070 | * |
@@ -2075,7 +2074,7 @@ discard block |
||
| 2075 | 2074 | * @param int|string $old_status The old comment status. |
| 2076 | 2075 | * @param object $comment The comment data. |
| 2077 | 2076 | */ |
| 2078 | - do_action( 'transition_comment_status', $new_status, $old_status, $comment ); |
|
| 2077 | + do_action('transition_comment_status', $new_status, $old_status, $comment); |
|
| 2079 | 2078 | /** |
| 2080 | 2079 | * Fires when the comment status is in transition from one specific status to another. |
| 2081 | 2080 | * |
@@ -2086,7 +2085,7 @@ discard block |
||
| 2086 | 2085 | * |
| 2087 | 2086 | * @param object $comment Comment object. |
| 2088 | 2087 | */ |
| 2089 | - do_action( "comment_{$old_status}_to_{$new_status}", $comment ); |
|
| 2088 | + do_action("comment_{$old_status}_to_{$new_status}", $comment); |
|
| 2090 | 2089 | } |
| 2091 | 2090 | /** |
| 2092 | 2091 | * Fires when the status of a specific comment type is in transition. |
@@ -2102,7 +2101,7 @@ discard block |
||
| 2102 | 2101 | * @param int $comment_ID The comment ID. |
| 2103 | 2102 | * @param obj $comment Comment object. |
| 2104 | 2103 | */ |
| 2105 | - do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment ); |
|
| 2104 | + do_action("comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment); |
|
| 2106 | 2105 | } |
| 2107 | 2106 | |
| 2108 | 2107 | /** |
@@ -2121,15 +2120,15 @@ discard block |
||
| 2121 | 2120 | // Cookies should already be sanitized. |
| 2122 | 2121 | |
| 2123 | 2122 | $comment_author = ''; |
| 2124 | - if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) |
|
| 2123 | + if (isset($_COOKIE['comment_author_'.COOKIEHASH])) |
|
| 2125 | 2124 | $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
| 2126 | 2125 | |
| 2127 | 2126 | $comment_author_email = ''; |
| 2128 | - if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) |
|
| 2127 | + if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) |
|
| 2129 | 2128 | $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
| 2130 | 2129 | |
| 2131 | 2130 | $comment_author_url = ''; |
| 2132 | - if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) |
|
| 2131 | + if (isset($_COOKIE['comment_author_url_'.COOKIEHASH])) |
|
| 2133 | 2132 | $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
| 2134 | 2133 | |
| 2135 | 2134 | /** |
@@ -2141,7 +2140,7 @@ discard block |
||
| 2141 | 2140 | * @param string $comment_author_email Comment author's email. |
| 2142 | 2141 | * @param string $comment_author_url Comment author's URL. |
| 2143 | 2142 | */ |
| 2144 | - return apply_filters( 'wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url') ); |
|
| 2143 | + return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')); |
|
| 2145 | 2144 | } |
| 2146 | 2145 | |
| 2147 | 2146 | /** |
@@ -2176,39 +2175,39 @@ discard block |
||
| 2176 | 2175 | * } |
| 2177 | 2176 | * @return int|false The new comment's ID on success, false on failure. |
| 2178 | 2177 | */ |
| 2179 | -function wp_insert_comment( $commentdata ) { |
|
| 2178 | +function wp_insert_comment($commentdata) { |
|
| 2180 | 2179 | global $wpdb; |
| 2181 | - $data = wp_unslash( $commentdata ); |
|
| 2180 | + $data = wp_unslash($commentdata); |
|
| 2182 | 2181 | |
| 2183 | - $comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author']; |
|
| 2184 | - $comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email']; |
|
| 2185 | - $comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url']; |
|
| 2186 | - $comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP']; |
|
| 2182 | + $comment_author = ! isset($data['comment_author']) ? '' : $data['comment_author']; |
|
| 2183 | + $comment_author_email = ! isset($data['comment_author_email']) ? '' : $data['comment_author_email']; |
|
| 2184 | + $comment_author_url = ! isset($data['comment_author_url']) ? '' : $data['comment_author_url']; |
|
| 2185 | + $comment_author_IP = ! isset($data['comment_author_IP']) ? '' : $data['comment_author_IP']; |
|
| 2187 | 2186 | |
| 2188 | - $comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date']; |
|
| 2189 | - $comment_date_gmt = ! isset( $data['comment_date_gmt'] ) ? get_gmt_from_date( $comment_date ) : $data['comment_date_gmt']; |
|
| 2187 | + $comment_date = ! isset($data['comment_date']) ? current_time('mysql') : $data['comment_date']; |
|
| 2188 | + $comment_date_gmt = ! isset($data['comment_date_gmt']) ? get_gmt_from_date($comment_date) : $data['comment_date_gmt']; |
|
| 2190 | 2189 | |
| 2191 | - $comment_post_ID = ! isset( $data['comment_post_ID'] ) ? '' : $data['comment_post_ID']; |
|
| 2192 | - $comment_content = ! isset( $data['comment_content'] ) ? '' : $data['comment_content']; |
|
| 2193 | - $comment_karma = ! isset( $data['comment_karma'] ) ? 0 : $data['comment_karma']; |
|
| 2194 | - $comment_approved = ! isset( $data['comment_approved'] ) ? 1 : $data['comment_approved']; |
|
| 2195 | - $comment_agent = ! isset( $data['comment_agent'] ) ? '' : $data['comment_agent']; |
|
| 2196 | - $comment_type = ! isset( $data['comment_type'] ) ? '' : $data['comment_type']; |
|
| 2197 | - $comment_parent = ! isset( $data['comment_parent'] ) ? 0 : $data['comment_parent']; |
|
| 2190 | + $comment_post_ID = ! isset($data['comment_post_ID']) ? '' : $data['comment_post_ID']; |
|
| 2191 | + $comment_content = ! isset($data['comment_content']) ? '' : $data['comment_content']; |
|
| 2192 | + $comment_karma = ! isset($data['comment_karma']) ? 0 : $data['comment_karma']; |
|
| 2193 | + $comment_approved = ! isset($data['comment_approved']) ? 1 : $data['comment_approved']; |
|
| 2194 | + $comment_agent = ! isset($data['comment_agent']) ? '' : $data['comment_agent']; |
|
| 2195 | + $comment_type = ! isset($data['comment_type']) ? '' : $data['comment_type']; |
|
| 2196 | + $comment_parent = ! isset($data['comment_parent']) ? 0 : $data['comment_parent']; |
|
| 2198 | 2197 | |
| 2199 | - $user_id = ! isset( $data['user_id'] ) ? 0 : $data['user_id']; |
|
| 2198 | + $user_id = ! isset($data['user_id']) ? 0 : $data['user_id']; |
|
| 2200 | 2199 | |
| 2201 | - $compacted = compact( 'comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id' ); |
|
| 2202 | - if ( ! $wpdb->insert( $wpdb->comments, $compacted ) ) { |
|
| 2200 | + $compacted = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id'); |
|
| 2201 | + if ( ! $wpdb->insert($wpdb->comments, $compacted)) { |
|
| 2203 | 2202 | return false; |
| 2204 | 2203 | } |
| 2205 | 2204 | |
| 2206 | 2205 | $id = (int) $wpdb->insert_id; |
| 2207 | 2206 | |
| 2208 | - if ( $comment_approved == 1 ) { |
|
| 2209 | - wp_update_comment_count( $comment_post_ID ); |
|
| 2207 | + if ($comment_approved == 1) { |
|
| 2208 | + wp_update_comment_count($comment_post_ID); |
|
| 2210 | 2209 | } |
| 2211 | - $comment = get_comment( $id ); |
|
| 2210 | + $comment = get_comment($id); |
|
| 2212 | 2211 | |
| 2213 | 2212 | /** |
| 2214 | 2213 | * Fires immediately after a comment is inserted into the database. |
@@ -2218,9 +2217,9 @@ discard block |
||
| 2218 | 2217 | * @param int $id The comment ID. |
| 2219 | 2218 | * @param obj $comment Comment object. |
| 2220 | 2219 | */ |
| 2221 | - do_action( 'wp_insert_comment', $id, $comment ); |
|
| 2220 | + do_action('wp_insert_comment', $id, $comment); |
|
| 2222 | 2221 | |
| 2223 | - wp_cache_set( 'last_changed', microtime(), 'comment' ); |
|
| 2222 | + wp_cache_set('last_changed', microtime(), 'comment'); |
|
| 2224 | 2223 | |
| 2225 | 2224 | return $id; |
| 2226 | 2225 | } |
@@ -2238,7 +2237,7 @@ discard block |
||
| 2238 | 2237 | * @return array Parsed comment information. |
| 2239 | 2238 | */ |
| 2240 | 2239 | function wp_filter_comment($commentdata) { |
| 2241 | - if ( isset( $commentdata['user_ID'] ) ) { |
|
| 2240 | + if (isset($commentdata['user_ID'])) { |
|
| 2242 | 2241 | /** |
| 2243 | 2242 | * Filter the comment author's user id before it is set. |
| 2244 | 2243 | * |
@@ -2249,10 +2248,10 @@ discard block |
||
| 2249 | 2248 | * |
| 2250 | 2249 | * @param int $user_ID The comment author's user ID. |
| 2251 | 2250 | */ |
| 2252 | - $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_ID'] ); |
|
| 2253 | - } elseif ( isset( $commentdata['user_id'] ) ) { |
|
| 2251 | + $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']); |
|
| 2252 | + } elseif (isset($commentdata['user_id'])) { |
|
| 2254 | 2253 | /** This filter is documented in wp-includes/comment.php */ |
| 2255 | - $commentdata['user_id'] = apply_filters( 'pre_user_id', $commentdata['user_id'] ); |
|
| 2254 | + $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_id']); |
|
| 2256 | 2255 | } |
| 2257 | 2256 | |
| 2258 | 2257 | /** |
@@ -2262,9 +2261,9 @@ discard block |
||
| 2262 | 2261 | * |
| 2263 | 2262 | * @param int $comment_agent The comment author's browser user agent. |
| 2264 | 2263 | */ |
| 2265 | - $commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) ); |
|
| 2264 | + $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', (isset($commentdata['comment_agent']) ? $commentdata['comment_agent'] : '')); |
|
| 2266 | 2265 | /** This filter is documented in wp-includes/comment.php */ |
| 2267 | - $commentdata['comment_author'] = apply_filters( 'pre_comment_author_name', $commentdata['comment_author'] ); |
|
| 2266 | + $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']); |
|
| 2268 | 2267 | /** |
| 2269 | 2268 | * Filter the comment content before it is set. |
| 2270 | 2269 | * |
@@ -2272,7 +2271,7 @@ discard block |
||
| 2272 | 2271 | * |
| 2273 | 2272 | * @param int $comment_content The comment content. |
| 2274 | 2273 | */ |
| 2275 | - $commentdata['comment_content'] = apply_filters( 'pre_comment_content', $commentdata['comment_content'] ); |
|
| 2274 | + $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']); |
|
| 2276 | 2275 | /** |
| 2277 | 2276 | * Filter the comment author's IP before it is set. |
| 2278 | 2277 | * |
@@ -2280,11 +2279,11 @@ discard block |
||
| 2280 | 2279 | * |
| 2281 | 2280 | * @param int $comment_author_ip The comment author's IP. |
| 2282 | 2281 | */ |
| 2283 | - $commentdata['comment_author_IP'] = apply_filters( 'pre_comment_user_ip', $commentdata['comment_author_IP'] ); |
|
| 2282 | + $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']); |
|
| 2284 | 2283 | /** This filter is documented in wp-includes/comment.php */ |
| 2285 | - $commentdata['comment_author_url'] = apply_filters( 'pre_comment_author_url', $commentdata['comment_author_url'] ); |
|
| 2284 | + $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']); |
|
| 2286 | 2285 | /** This filter is documented in wp-includes/comment.php */ |
| 2287 | - $commentdata['comment_author_email'] = apply_filters( 'pre_comment_author_email', $commentdata['comment_author_email'] ); |
|
| 2286 | + $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']); |
|
| 2288 | 2287 | $commentdata['filtered'] = true; |
| 2289 | 2288 | return $commentdata; |
| 2290 | 2289 | } |
@@ -2300,9 +2299,9 @@ discard block |
||
| 2300 | 2299 | * @return bool Whether comment should be blocked. |
| 2301 | 2300 | */ |
| 2302 | 2301 | function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { |
| 2303 | - if ( $block ) // a plugin has already blocked... we'll let that decision stand |
|
| 2302 | + if ($block) // a plugin has already blocked... we'll let that decision stand |
|
| 2304 | 2303 | return $block; |
| 2305 | - if ( ($time_newcomment - $time_lastcomment) < 15 ) |
|
| 2304 | + if (($time_newcomment - $time_lastcomment) < 15) |
|
| 2306 | 2305 | return true; |
| 2307 | 2306 | return false; |
| 2308 | 2307 | } |
@@ -2330,14 +2329,14 @@ discard block |
||
| 2330 | 2329 | * for information on accepted arguments. |
| 2331 | 2330 | * @return int|false The ID of the comment on success, false on failure. |
| 2332 | 2331 | */ |
| 2333 | -function wp_new_comment( $commentdata ) { |
|
| 2332 | +function wp_new_comment($commentdata) { |
|
| 2334 | 2333 | global $wpdb; |
| 2335 | 2334 | |
| 2336 | - if ( isset( $commentdata['user_ID'] ) ) { |
|
| 2335 | + if (isset($commentdata['user_ID'])) { |
|
| 2337 | 2336 | $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; |
| 2338 | 2337 | } |
| 2339 | 2338 | |
| 2340 | - $prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0; |
|
| 2339 | + $prefiltered_user_id = (isset($commentdata['user_id'])) ? (int) $commentdata['user_id'] : 0; |
|
| 2341 | 2340 | |
| 2342 | 2341 | /** |
| 2343 | 2342 | * Filter a comment's data before it is sanitized and inserted into the database. |
@@ -2346,35 +2345,35 @@ discard block |
||
| 2346 | 2345 | * |
| 2347 | 2346 | * @param array $commentdata Comment data. |
| 2348 | 2347 | */ |
| 2349 | - $commentdata = apply_filters( 'preprocess_comment', $commentdata ); |
|
| 2348 | + $commentdata = apply_filters('preprocess_comment', $commentdata); |
|
| 2350 | 2349 | |
| 2351 | 2350 | $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID']; |
| 2352 | - if ( isset( $commentdata['user_ID'] ) && $prefiltered_user_id !== (int) $commentdata['user_ID'] ) { |
|
| 2351 | + if (isset($commentdata['user_ID']) && $prefiltered_user_id !== (int) $commentdata['user_ID']) { |
|
| 2353 | 2352 | $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID']; |
| 2354 | - } elseif ( isset( $commentdata['user_id'] ) ) { |
|
| 2353 | + } elseif (isset($commentdata['user_id'])) { |
|
| 2355 | 2354 | $commentdata['user_id'] = (int) $commentdata['user_id']; |
| 2356 | 2355 | } |
| 2357 | 2356 | |
| 2358 | 2357 | $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; |
| 2359 | - $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; |
|
| 2360 | - $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; |
|
| 2358 | + $parent_status = (0 < $commentdata['comment_parent']) ? wp_get_comment_status($commentdata['comment_parent']) : ''; |
|
| 2359 | + $commentdata['comment_parent'] = ('approved' == $parent_status || 'unapproved' == $parent_status) ? $commentdata['comment_parent'] : 0; |
|
| 2361 | 2360 | |
| 2362 | - if ( ! isset( $commentdata['comment_author_IP'] ) ) { |
|
| 2361 | + if ( ! isset($commentdata['comment_author_IP'])) { |
|
| 2363 | 2362 | $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR']; |
| 2364 | 2363 | } |
| 2365 | - $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] ); |
|
| 2364 | + $commentdata['comment_author_IP'] = preg_replace('/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP']); |
|
| 2366 | 2365 | |
| 2367 | - if ( ! isset( $commentdata['comment_agent'] ) ) { |
|
| 2368 | - $commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT']: ''; |
|
| 2366 | + if ( ! isset($commentdata['comment_agent'])) { |
|
| 2367 | + $commentdata['comment_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 2369 | 2368 | } |
| 2370 | - $commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 ); |
|
| 2369 | + $commentdata['comment_agent'] = substr($commentdata['comment_agent'], 0, 254); |
|
| 2371 | 2370 | |
| 2372 | - if ( empty( $commentdata['comment_date'] ) ) { |
|
| 2371 | + if (empty($commentdata['comment_date'])) { |
|
| 2373 | 2372 | $commentdata['comment_date'] = current_time('mysql'); |
| 2374 | 2373 | } |
| 2375 | 2374 | |
| 2376 | - if ( empty( $commentdata['comment_date_gmt'] ) ) { |
|
| 2377 | - $commentdata['comment_date_gmt'] = current_time( 'mysql', 1 ); |
|
| 2375 | + if (empty($commentdata['comment_date_gmt'])) { |
|
| 2376 | + $commentdata['comment_date_gmt'] = current_time('mysql', 1); |
|
| 2378 | 2377 | } |
| 2379 | 2378 | |
| 2380 | 2379 | $commentdata = wp_filter_comment($commentdata); |
@@ -2382,21 +2381,21 @@ discard block |
||
| 2382 | 2381 | $commentdata['comment_approved'] = wp_allow_comment($commentdata); |
| 2383 | 2382 | |
| 2384 | 2383 | $comment_ID = wp_insert_comment($commentdata); |
| 2385 | - if ( ! $comment_ID ) { |
|
| 2386 | - $fields = array( 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content' ); |
|
| 2384 | + if ( ! $comment_ID) { |
|
| 2385 | + $fields = array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_content'); |
|
| 2387 | 2386 | |
| 2388 | - foreach( $fields as $field ) { |
|
| 2389 | - if ( isset( $commentdata[ $field ] ) ) { |
|
| 2390 | - $commentdata[ $field ] = $wpdb->strip_invalid_text_for_column( $wpdb->comments, $field, $commentdata[ $field ] ); |
|
| 2387 | + foreach ($fields as $field) { |
|
| 2388 | + if (isset($commentdata[$field])) { |
|
| 2389 | + $commentdata[$field] = $wpdb->strip_invalid_text_for_column($wpdb->comments, $field, $commentdata[$field]); |
|
| 2391 | 2390 | } |
| 2392 | 2391 | } |
| 2393 | 2392 | |
| 2394 | - $commentdata = wp_filter_comment( $commentdata ); |
|
| 2393 | + $commentdata = wp_filter_comment($commentdata); |
|
| 2395 | 2394 | |
| 2396 | - $commentdata['comment_approved'] = wp_allow_comment( $commentdata ); |
|
| 2395 | + $commentdata['comment_approved'] = wp_allow_comment($commentdata); |
|
| 2397 | 2396 | |
| 2398 | - $comment_ID = wp_insert_comment( $commentdata ); |
|
| 2399 | - if ( ! $comment_ID ) { |
|
| 2397 | + $comment_ID = wp_insert_comment($commentdata); |
|
| 2398 | + if ( ! $comment_ID) { |
|
| 2400 | 2399 | return false; |
| 2401 | 2400 | } |
| 2402 | 2401 | } |
@@ -2409,17 +2408,17 @@ discard block |
||
| 2409 | 2408 | * @param int $comment_ID The comment ID. |
| 2410 | 2409 | * @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not. |
| 2411 | 2410 | */ |
| 2412 | - do_action( 'comment_post', $comment_ID, $commentdata['comment_approved'] ); |
|
| 2411 | + do_action('comment_post', $comment_ID, $commentdata['comment_approved']); |
|
| 2413 | 2412 | |
| 2414 | - if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching |
|
| 2415 | - if ( '0' == $commentdata['comment_approved'] ) { |
|
| 2416 | - wp_notify_moderator( $comment_ID ); |
|
| 2413 | + if ('spam' !== $commentdata['comment_approved']) { // If it's spam save it silently for later crunching |
|
| 2414 | + if ('0' == $commentdata['comment_approved']) { |
|
| 2415 | + wp_notify_moderator($comment_ID); |
|
| 2417 | 2416 | } |
| 2418 | 2417 | |
| 2419 | 2418 | // wp_notify_postauthor() checks if notifying the author of their own comment. |
| 2420 | 2419 | // By default, it won't, but filters can override this. |
| 2421 | - if ( get_option( 'comments_notify' ) && $commentdata['comment_approved'] ) { |
|
| 2422 | - wp_notify_postauthor( $comment_ID ); |
|
| 2420 | + if (get_option('comments_notify') && $commentdata['comment_approved']) { |
|
| 2421 | + wp_notify_postauthor($comment_ID); |
|
| 2423 | 2422 | } |
| 2424 | 2423 | } |
| 2425 | 2424 | |
@@ -2444,7 +2443,7 @@ discard block |
||
| 2444 | 2443 | function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { |
| 2445 | 2444 | global $wpdb; |
| 2446 | 2445 | |
| 2447 | - switch ( $comment_status ) { |
|
| 2446 | + switch ($comment_status) { |
|
| 2448 | 2447 | case 'hold': |
| 2449 | 2448 | case '0': |
| 2450 | 2449 | $status = '0'; |
@@ -2452,8 +2451,8 @@ discard block |
||
| 2452 | 2451 | case 'approve': |
| 2453 | 2452 | case '1': |
| 2454 | 2453 | $status = '1'; |
| 2455 | - if ( get_option('comments_notify') ) { |
|
| 2456 | - wp_notify_postauthor( $comment_id ); |
|
| 2454 | + if (get_option('comments_notify')) { |
|
| 2455 | + wp_notify_postauthor($comment_id); |
|
| 2457 | 2456 | } |
| 2458 | 2457 | break; |
| 2459 | 2458 | case 'spam': |
@@ -2468,8 +2467,8 @@ discard block |
||
| 2468 | 2467 | |
| 2469 | 2468 | $comment_old = clone get_comment($comment_id); |
| 2470 | 2469 | |
| 2471 | - if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) { |
|
| 2472 | - if ( $wp_error ) |
|
| 2470 | + if ( ! $wpdb->update($wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id))) { |
|
| 2471 | + if ($wp_error) |
|
| 2473 | 2472 | return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
| 2474 | 2473 | else |
| 2475 | 2474 | return false; |
@@ -2489,7 +2488,7 @@ discard block |
||
| 2489 | 2488 | * @param string|bool $comment_status Current comment status. Possible values include |
| 2490 | 2489 | * 'hold', 'approve', 'spam', 'trash', or false. |
| 2491 | 2490 | */ |
| 2492 | - do_action( 'wp_set_comment_status', $comment_id, $comment_status ); |
|
| 2491 | + do_action('wp_set_comment_status', $comment_id, $comment_status); |
|
| 2493 | 2492 | |
| 2494 | 2493 | wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); |
| 2495 | 2494 | |
@@ -2515,12 +2514,12 @@ discard block |
||
| 2515 | 2514 | |
| 2516 | 2515 | // First, get all of the original fields |
| 2517 | 2516 | $comment = get_comment($commentarr['comment_ID'], ARRAY_A); |
| 2518 | - if ( empty( $comment ) ) { |
|
| 2517 | + if (empty($comment)) { |
|
| 2519 | 2518 | return 0; |
| 2520 | 2519 | } |
| 2521 | 2520 | |
| 2522 | 2521 | // Make sure that the comment post ID is valid (if specified). |
| 2523 | - if ( isset( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) { |
|
| 2522 | + if (isset($commentarr['comment_post_ID']) && ! get_post($commentarr['comment_post_ID'])) { |
|
| 2524 | 2523 | return 0; |
| 2525 | 2524 | } |
| 2526 | 2525 | |
@@ -2532,10 +2531,10 @@ discard block |
||
| 2532 | 2531 | // Merge old and new fields with new fields overwriting old ones. |
| 2533 | 2532 | $commentarr = array_merge($comment, $commentarr); |
| 2534 | 2533 | |
| 2535 | - $commentarr = wp_filter_comment( $commentarr ); |
|
| 2534 | + $commentarr = wp_filter_comment($commentarr); |
|
| 2536 | 2535 | |
| 2537 | 2536 | // Now extract the merged array. |
| 2538 | - $data = wp_unslash( $commentarr ); |
|
| 2537 | + $data = wp_unslash($commentarr); |
|
| 2539 | 2538 | |
| 2540 | 2539 | /** |
| 2541 | 2540 | * Filter the comment content before it is updated in the database. |
@@ -2544,26 +2543,26 @@ discard block |
||
| 2544 | 2543 | * |
| 2545 | 2544 | * @param string $comment_content The comment data. |
| 2546 | 2545 | */ |
| 2547 | - $data['comment_content'] = apply_filters( 'comment_save_pre', $data['comment_content'] ); |
|
| 2546 | + $data['comment_content'] = apply_filters('comment_save_pre', $data['comment_content']); |
|
| 2548 | 2547 | |
| 2549 | - $data['comment_date_gmt'] = get_gmt_from_date( $data['comment_date'] ); |
|
| 2548 | + $data['comment_date_gmt'] = get_gmt_from_date($data['comment_date']); |
|
| 2550 | 2549 | |
| 2551 | - if ( ! isset( $data['comment_approved'] ) ) { |
|
| 2550 | + if ( ! isset($data['comment_approved'])) { |
|
| 2552 | 2551 | $data['comment_approved'] = 1; |
| 2553 | - } elseif ( 'hold' == $data['comment_approved'] ) { |
|
| 2552 | + } elseif ('hold' == $data['comment_approved']) { |
|
| 2554 | 2553 | $data['comment_approved'] = 0; |
| 2555 | - } elseif ( 'approve' == $data['comment_approved'] ) { |
|
| 2554 | + } elseif ('approve' == $data['comment_approved']) { |
|
| 2556 | 2555 | $data['comment_approved'] = 1; |
| 2557 | 2556 | } |
| 2558 | 2557 | |
| 2559 | 2558 | $comment_ID = $data['comment_ID']; |
| 2560 | 2559 | $comment_post_ID = $data['comment_post_ID']; |
| 2561 | - $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id' ); |
|
| 2562 | - $data = wp_array_slice_assoc( $data, $keys ); |
|
| 2563 | - $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); |
|
| 2560 | + $keys = array('comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id'); |
|
| 2561 | + $data = wp_array_slice_assoc($data, $keys); |
|
| 2562 | + $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID')); |
|
| 2564 | 2563 | |
| 2565 | - clean_comment_cache( $comment_ID ); |
|
| 2566 | - wp_update_comment_count( $comment_post_ID ); |
|
| 2564 | + clean_comment_cache($comment_ID); |
|
| 2565 | + wp_update_comment_count($comment_post_ID); |
|
| 2567 | 2566 | /** |
| 2568 | 2567 | * Fires immediately after a comment is updated in the database. |
| 2569 | 2568 | * |
@@ -2573,7 +2572,7 @@ discard block |
||
| 2573 | 2572 | * |
| 2574 | 2573 | * @param int $comment_ID The comment ID. |
| 2575 | 2574 | */ |
| 2576 | - do_action( 'edit_comment', $comment_ID ); |
|
| 2575 | + do_action('edit_comment', $comment_ID); |
|
| 2577 | 2576 | $comment = get_comment($comment_ID); |
| 2578 | 2577 | wp_transition_comment_status($comment->comment_approved, $old_status, $comment); |
| 2579 | 2578 | return $rval; |
@@ -2593,14 +2592,14 @@ discard block |
||
| 2593 | 2592 | * @param bool $defer |
| 2594 | 2593 | * @return bool |
| 2595 | 2594 | */ |
| 2596 | -function wp_defer_comment_counting($defer=null) { |
|
| 2595 | +function wp_defer_comment_counting($defer = null) { |
|
| 2597 | 2596 | static $_defer = false; |
| 2598 | 2597 | |
| 2599 | - if ( is_bool($defer) ) { |
|
| 2598 | + if (is_bool($defer)) { |
|
| 2600 | 2599 | $_defer = $defer; |
| 2601 | 2600 | // flush any deferred counts |
| 2602 | - if ( !$defer ) |
|
| 2603 | - wp_update_comment_count( null, true ); |
|
| 2601 | + if ( ! $defer) |
|
| 2602 | + wp_update_comment_count(null, true); |
|
| 2604 | 2603 | } |
| 2605 | 2604 | |
| 2606 | 2605 | return $_defer; |
@@ -2626,22 +2625,22 @@ discard block |
||
| 2626 | 2625 | * @param bool $do_deferred Whether to process previously deferred post comment counts |
| 2627 | 2626 | * @return bool|void True on success, false on failure |
| 2628 | 2627 | */ |
| 2629 | -function wp_update_comment_count($post_id, $do_deferred=false) { |
|
| 2628 | +function wp_update_comment_count($post_id, $do_deferred = false) { |
|
| 2630 | 2629 | static $_deferred = array(); |
| 2631 | 2630 | |
| 2632 | - if ( $do_deferred ) { |
|
| 2631 | + if ($do_deferred) { |
|
| 2633 | 2632 | $_deferred = array_unique($_deferred); |
| 2634 | - foreach ( $_deferred as $i => $_post_id ) { |
|
| 2633 | + foreach ($_deferred as $i => $_post_id) { |
|
| 2635 | 2634 | wp_update_comment_count_now($_post_id); |
| 2636 | - unset( $_deferred[$i] ); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ |
|
| 2635 | + unset($_deferred[$i]); /** @todo Move this outside of the foreach and reset $_deferred to an array instead */ |
|
| 2637 | 2636 | } |
| 2638 | 2637 | } |
| 2639 | 2638 | |
| 2640 | - if ( wp_defer_comment_counting() ) { |
|
| 2639 | + if (wp_defer_comment_counting()) { |
|
| 2641 | 2640 | $_deferred[] = $post_id; |
| 2642 | 2641 | return true; |
| 2643 | 2642 | } |
| 2644 | - elseif ( $post_id ) { |
|
| 2643 | + elseif ($post_id) { |
|
| 2645 | 2644 | return wp_update_comment_count_now($post_id); |
| 2646 | 2645 | } |
| 2647 | 2646 | |
@@ -2660,16 +2659,16 @@ discard block |
||
| 2660 | 2659 | function wp_update_comment_count_now($post_id) { |
| 2661 | 2660 | global $wpdb; |
| 2662 | 2661 | $post_id = (int) $post_id; |
| 2663 | - if ( !$post_id ) |
|
| 2662 | + if ( ! $post_id) |
|
| 2664 | 2663 | return false; |
| 2665 | - if ( !$post = get_post($post_id) ) |
|
| 2664 | + if ( ! $post = get_post($post_id)) |
|
| 2666 | 2665 | return false; |
| 2667 | 2666 | |
| 2668 | 2667 | $old = (int) $post->comment_count; |
| 2669 | - $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); |
|
| 2670 | - $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) ); |
|
| 2668 | + $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id)); |
|
| 2669 | + $wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post_id)); |
|
| 2671 | 2670 | |
| 2672 | - clean_post_cache( $post ); |
|
| 2671 | + clean_post_cache($post); |
|
| 2673 | 2672 | |
| 2674 | 2673 | /** |
| 2675 | 2674 | * Fires immediately after a post's comment count is updated in the database. |
@@ -2680,9 +2679,9 @@ discard block |
||
| 2680 | 2679 | * @param int $new The new comment count. |
| 2681 | 2680 | * @param int $old The old comment count. |
| 2682 | 2681 | */ |
| 2683 | - do_action( 'wp_update_comment_count', $post_id, $new, $old ); |
|
| 2682 | + do_action('wp_update_comment_count', $post_id, $new, $old); |
|
| 2684 | 2683 | /** This action is documented in wp-includes/post.php */ |
| 2685 | - do_action( 'edit_post', $post_id, $post ); |
|
| 2684 | + do_action('edit_post', $post_id, $post); |
|
| 2686 | 2685 | |
| 2687 | 2686 | return true; |
| 2688 | 2687 | } |
@@ -2704,9 +2703,9 @@ discard block |
||
| 2704 | 2703 | * @param int $deprecated Not Used. |
| 2705 | 2704 | * @return false|string False on failure, string containing URI on success. |
| 2706 | 2705 | */ |
| 2707 | -function discover_pingback_server_uri( $url, $deprecated = '' ) { |
|
| 2708 | - if ( !empty( $deprecated ) ) |
|
| 2709 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2706 | +function discover_pingback_server_uri($url, $deprecated = '') { |
|
| 2707 | + if ( ! empty($deprecated)) |
|
| 2708 | + _deprecated_argument(__FUNCTION__, '2.7'); |
|
| 2710 | 2709 | |
| 2711 | 2710 | $pingback_str_dquote = 'rel="pingback"'; |
| 2712 | 2711 | $pingback_str_squote = 'rel=\'pingback\''; |
@@ -2714,47 +2713,47 @@ discard block |
||
| 2714 | 2713 | /** @todo Should use Filter Extension or custom preg_match instead. */ |
| 2715 | 2714 | $parsed_url = parse_url($url); |
| 2716 | 2715 | |
| 2717 | - if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen. |
|
| 2716 | + if ( ! isset($parsed_url['host'])) // Not an URL. This should never happen. |
|
| 2718 | 2717 | return false; |
| 2719 | 2718 | |
| 2720 | 2719 | //Do not search for a pingback server on our own uploads |
| 2721 | 2720 | $uploads_dir = wp_upload_dir(); |
| 2722 | - if ( 0 === strpos($url, $uploads_dir['baseurl']) ) |
|
| 2721 | + if (0 === strpos($url, $uploads_dir['baseurl'])) |
|
| 2723 | 2722 | return false; |
| 2724 | 2723 | |
| 2725 | - $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
|
| 2724 | + $response = wp_safe_remote_head($url, array('timeout' => 2, 'httpversion' => '1.0')); |
|
| 2726 | 2725 | |
| 2727 | - if ( is_wp_error( $response ) ) |
|
| 2726 | + if (is_wp_error($response)) |
|
| 2728 | 2727 | return false; |
| 2729 | 2728 | |
| 2730 | - if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) |
|
| 2731 | - return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2729 | + if (wp_remote_retrieve_header($response, 'x-pingback')) |
|
| 2730 | + return wp_remote_retrieve_header($response, 'x-pingback'); |
|
| 2732 | 2731 | |
| 2733 | 2732 | // Not an (x)html, sgml, or xml page, no use going further. |
| 2734 | - if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) |
|
| 2733 | + if (preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header($response, 'content-type'))) |
|
| 2735 | 2734 | return false; |
| 2736 | 2735 | |
| 2737 | 2736 | // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) |
| 2738 | - $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
|
| 2737 | + $response = wp_safe_remote_get($url, array('timeout' => 2, 'httpversion' => '1.0')); |
|
| 2739 | 2738 | |
| 2740 | - if ( is_wp_error( $response ) ) |
|
| 2739 | + if (is_wp_error($response)) |
|
| 2741 | 2740 | return false; |
| 2742 | 2741 | |
| 2743 | - $contents = wp_remote_retrieve_body( $response ); |
|
| 2742 | + $contents = wp_remote_retrieve_body($response); |
|
| 2744 | 2743 | |
| 2745 | 2744 | $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); |
| 2746 | 2745 | $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); |
| 2747 | - if ( $pingback_link_offset_dquote || $pingback_link_offset_squote ) { |
|
| 2746 | + if ($pingback_link_offset_dquote || $pingback_link_offset_squote) { |
|
| 2748 | 2747 | $quote = ($pingback_link_offset_dquote) ? '"' : '\''; |
| 2749 | - $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; |
|
| 2748 | + $pingback_link_offset = ($quote == '"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote; |
|
| 2750 | 2749 | $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset); |
| 2751 | - $pingback_href_start = $pingback_href_pos+6; |
|
| 2750 | + $pingback_href_start = $pingback_href_pos + 6; |
|
| 2752 | 2751 | $pingback_href_end = @strpos($contents, $quote, $pingback_href_start); |
| 2753 | 2752 | $pingback_server_url_len = $pingback_href_end - $pingback_href_start; |
| 2754 | 2753 | $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len); |
| 2755 | 2754 | |
| 2756 | 2755 | // We may find rel="pingback" but an incomplete pingback URL |
| 2757 | - if ( $pingback_server_url_len > 0 ) { // We got it! |
|
| 2756 | + if ($pingback_server_url_len > 0) { // We got it! |
|
| 2758 | 2757 | return $pingback_server_url; |
| 2759 | 2758 | } |
| 2760 | 2759 | } |
@@ -2774,20 +2773,20 @@ discard block |
||
| 2774 | 2773 | |
| 2775 | 2774 | // Do pingbacks |
| 2776 | 2775 | while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { |
| 2777 | - delete_metadata_by_mid( 'post', $ping->meta_id ); |
|
| 2778 | - pingback( $ping->post_content, $ping->ID ); |
|
| 2776 | + delete_metadata_by_mid('post', $ping->meta_id); |
|
| 2777 | + pingback($ping->post_content, $ping->ID); |
|
| 2779 | 2778 | } |
| 2780 | 2779 | |
| 2781 | 2780 | // Do Enclosures |
| 2782 | 2781 | while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { |
| 2783 | - delete_metadata_by_mid( 'post', $enclosure->meta_id ); |
|
| 2784 | - do_enclose( $enclosure->post_content, $enclosure->ID ); |
|
| 2782 | + delete_metadata_by_mid('post', $enclosure->meta_id); |
|
| 2783 | + do_enclose($enclosure->post_content, $enclosure->ID); |
|
| 2785 | 2784 | } |
| 2786 | 2785 | |
| 2787 | 2786 | // Do Trackbacks |
| 2788 | 2787 | $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); |
| 2789 | - if ( is_array($trackbacks) ) |
|
| 2790 | - foreach ( $trackbacks as $trackback ) |
|
| 2788 | + if (is_array($trackbacks)) |
|
| 2789 | + foreach ($trackbacks as $trackback) |
|
| 2791 | 2790 | do_trackbacks($trackback); |
| 2792 | 2791 | |
| 2793 | 2792 | //Do Update Services/Generic Pings |
@@ -2806,37 +2805,37 @@ discard block |
||
| 2806 | 2805 | function do_trackbacks($post_id) { |
| 2807 | 2806 | global $wpdb; |
| 2808 | 2807 | |
| 2809 | - $post = get_post( $post_id ); |
|
| 2808 | + $post = get_post($post_id); |
|
| 2810 | 2809 | $to_ping = get_to_ping($post_id); |
| 2811 | 2810 | $pinged = get_pung($post_id); |
| 2812 | - if ( empty($to_ping) ) { |
|
| 2813 | - $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id) ); |
|
| 2811 | + if (empty($to_ping)) { |
|
| 2812 | + $wpdb->update($wpdb->posts, array('to_ping' => ''), array('ID' => $post_id)); |
|
| 2814 | 2813 | return; |
| 2815 | 2814 | } |
| 2816 | 2815 | |
| 2817 | - if ( empty($post->post_excerpt) ) { |
|
| 2816 | + if (empty($post->post_excerpt)) { |
|
| 2818 | 2817 | /** This filter is documented in wp-includes/post-template.php */ |
| 2819 | - $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); |
|
| 2818 | + $excerpt = apply_filters('the_content', $post->post_content, $post->ID); |
|
| 2820 | 2819 | } else { |
| 2821 | 2820 | /** This filter is documented in wp-includes/post-template.php */ |
| 2822 | - $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); |
|
| 2821 | + $excerpt = apply_filters('the_excerpt', $post->post_excerpt); |
|
| 2823 | 2822 | } |
| 2824 | 2823 | |
| 2825 | 2824 | $excerpt = str_replace(']]>', ']]>', $excerpt); |
| 2826 | 2825 | $excerpt = wp_html_excerpt($excerpt, 252, '…'); |
| 2827 | 2826 | |
| 2828 | 2827 | /** This filter is documented in wp-includes/post-template.php */ |
| 2829 | - $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); |
|
| 2828 | + $post_title = apply_filters('the_title', $post->post_title, $post->ID); |
|
| 2830 | 2829 | $post_title = strip_tags($post_title); |
| 2831 | 2830 | |
| 2832 | - if ( $to_ping ) { |
|
| 2833 | - foreach ( (array) $to_ping as $tb_ping ) { |
|
| 2831 | + if ($to_ping) { |
|
| 2832 | + foreach ((array) $to_ping as $tb_ping) { |
|
| 2834 | 2833 | $tb_ping = trim($tb_ping); |
| 2835 | - if ( !in_array($tb_ping, $pinged) ) { |
|
| 2834 | + if ( ! in_array($tb_ping, $pinged)) { |
|
| 2836 | 2835 | trackback($tb_ping, $post_title, $excerpt, $post_id); |
| 2837 | 2836 | $pinged[] = $tb_ping; |
| 2838 | 2837 | } else { |
| 2839 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id) ); |
|
| 2838 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $tb_ping, $post_id)); |
|
| 2840 | 2839 | } |
| 2841 | 2840 | } |
| 2842 | 2841 | } |
@@ -2850,13 +2849,13 @@ discard block |
||
| 2850 | 2849 | * @param int $post_id Post ID. |
| 2851 | 2850 | * @return int Same as Post ID from parameter |
| 2852 | 2851 | */ |
| 2853 | -function generic_ping( $post_id = 0 ) { |
|
| 2852 | +function generic_ping($post_id = 0) { |
|
| 2854 | 2853 | $services = get_option('ping_sites'); |
| 2855 | 2854 | |
| 2856 | 2855 | $services = explode("\n", $services); |
| 2857 | - foreach ( (array) $services as $service ) { |
|
| 2856 | + foreach ((array) $services as $service) { |
|
| 2858 | 2857 | $service = trim($service); |
| 2859 | - if ( '' != $service ) |
|
| 2858 | + if ('' != $service) |
|
| 2860 | 2859 | weblog_ping($service); |
| 2861 | 2860 | } |
| 2862 | 2861 | |
@@ -2875,8 +2874,8 @@ discard block |
||
| 2875 | 2874 | */ |
| 2876 | 2875 | function pingback($content, $post_ID) { |
| 2877 | 2876 | global $wp_version; |
| 2878 | - include_once(ABSPATH . WPINC . '/class-IXR.php'); |
|
| 2879 | - include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); |
|
| 2877 | + include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
| 2878 | + include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php'); |
|
| 2880 | 2879 | |
| 2881 | 2880 | // original code by Mort (http://mort.mine.nu:8080) |
| 2882 | 2881 | $post_links = array(); |
@@ -2885,7 +2884,7 @@ discard block |
||
| 2885 | 2884 | |
| 2886 | 2885 | // Step 1 |
| 2887 | 2886 | // Parsing the post, external links (if any) are stored in the $post_links array |
| 2888 | - $post_links_temp = wp_extract_urls( $content ); |
|
| 2887 | + $post_links_temp = wp_extract_urls($content); |
|
| 2889 | 2888 | |
| 2890 | 2889 | // Step 2. |
| 2891 | 2890 | // Walking thru the links array |
@@ -2896,19 +2895,19 @@ discard block |
||
| 2896 | 2895 | // http://dummy-weblog.org/post.php |
| 2897 | 2896 | // We don't wanna ping first and second types, even if they have a valid <link/> |
| 2898 | 2897 | |
| 2899 | - foreach ( (array) $post_links_temp as $link_test ) : |
|
| 2900 | - if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
|
| 2901 | - && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. |
|
| 2902 | - if ( $test = @parse_url($link_test) ) { |
|
| 2903 | - if ( isset($test['query']) ) |
|
| 2898 | + foreach ((array) $post_links_temp as $link_test) : |
|
| 2899 | + if ( ! in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
|
| 2900 | + && ! is_local_attachment($link_test)) : // Also, let's never ping local attachments. |
|
| 2901 | + if ($test = @parse_url($link_test)) { |
|
| 2902 | + if (isset($test['query'])) |
|
| 2904 | 2903 | $post_links[] = $link_test; |
| 2905 | - elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) |
|
| 2904 | + elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != '')) |
|
| 2906 | 2905 | $post_links[] = $link_test; |
| 2907 | 2906 | } |
| 2908 | 2907 | endif; |
| 2909 | 2908 | endforeach; |
| 2910 | 2909 | |
| 2911 | - $post_links = array_unique( $post_links ); |
|
| 2910 | + $post_links = array_unique($post_links); |
|
| 2912 | 2911 | /** |
| 2913 | 2912 | * Fires just before pinging back links found in a post. |
| 2914 | 2913 | * |
@@ -2918,13 +2917,13 @@ discard block |
||
| 2918 | 2917 | * @param array &$pung Whether a link has already been pinged, passed by reference. |
| 2919 | 2918 | * @param int $post_ID The post ID. |
| 2920 | 2919 | */ |
| 2921 | - do_action_ref_array( 'pre_ping', array( &$post_links, &$pung, $post_ID ) ); |
|
| 2920 | + do_action_ref_array('pre_ping', array(&$post_links, &$pung, $post_ID)); |
|
| 2922 | 2921 | |
| 2923 | - foreach ( (array) $post_links as $pagelinkedto ) { |
|
| 2924 | - $pingback_server_url = discover_pingback_server_uri( $pagelinkedto ); |
|
| 2922 | + foreach ((array) $post_links as $pagelinkedto) { |
|
| 2923 | + $pingback_server_url = discover_pingback_server_uri($pagelinkedto); |
|
| 2925 | 2924 | |
| 2926 | - if ( $pingback_server_url ) { |
|
| 2927 | - @ set_time_limit( 60 ); |
|
| 2925 | + if ($pingback_server_url) { |
|
| 2926 | + @ set_time_limit(60); |
|
| 2928 | 2927 | // Now, the RPC call |
| 2929 | 2928 | $pagelinkedfrom = get_permalink($post_ID); |
| 2930 | 2929 | |
@@ -2943,12 +2942,12 @@ discard block |
||
| 2943 | 2942 | * @param string $pagelinkedto URL of page linked to. |
| 2944 | 2943 | * @param string $pagelinkedfrom URL of page linked from. |
| 2945 | 2944 | */ |
| 2946 | - $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . $wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); |
|
| 2945 | + $client->useragent = apply_filters('pingback_useragent', $client->useragent.' -- WordPress/'.$wp_version, $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom); |
|
| 2947 | 2946 | // when set to true, this outputs debug messages by itself |
| 2948 | 2947 | $client->debug = false; |
| 2949 | 2948 | |
| 2950 | - if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered |
|
| 2951 | - add_ping( $post_ID, $pagelinkedto ); |
|
| 2949 | + if ($client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || (isset($client->error->code) && 48 == $client->error->code)) // Already registered |
|
| 2950 | + add_ping($post_ID, $pagelinkedto); |
|
| 2952 | 2951 | } |
| 2953 | 2952 | } |
| 2954 | 2953 | } |
@@ -2962,7 +2961,7 @@ discard block |
||
| 2962 | 2961 | * @return mixed Empty string if blog is not public, returns $sites, if site is public. |
| 2963 | 2962 | */ |
| 2964 | 2963 | function privacy_ping_filter($sites) { |
| 2965 | - if ( '0' != get_option('blog_public') ) |
|
| 2964 | + if ('0' != get_option('blog_public')) |
|
| 2966 | 2965 | return $sites; |
| 2967 | 2966 | else |
| 2968 | 2967 | return ''; |
@@ -2986,7 +2985,7 @@ discard block |
||
| 2986 | 2985 | function trackback($trackback_url, $title, $excerpt, $ID) { |
| 2987 | 2986 | global $wpdb; |
| 2988 | 2987 | |
| 2989 | - if ( empty($trackback_url) ) |
|
| 2988 | + if (empty($trackback_url)) |
|
| 2990 | 2989 | return; |
| 2991 | 2990 | |
| 2992 | 2991 | $options = array(); |
@@ -2998,13 +2997,13 @@ discard block |
||
| 2998 | 2997 | 'excerpt' => $excerpt |
| 2999 | 2998 | ); |
| 3000 | 2999 | |
| 3001 | - $response = wp_safe_remote_post( $trackback_url, $options ); |
|
| 3000 | + $response = wp_safe_remote_post($trackback_url, $options); |
|
| 3002 | 3001 | |
| 3003 | - if ( is_wp_error( $response ) ) |
|
| 3002 | + if (is_wp_error($response)) |
|
| 3004 | 3003 | return; |
| 3005 | 3004 | |
| 3006 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); |
|
| 3007 | - return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); |
|
| 3005 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID)); |
|
| 3006 | + return $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID)); |
|
| 3008 | 3007 | } |
| 3009 | 3008 | |
| 3010 | 3009 | /** |
@@ -3019,18 +3018,18 @@ discard block |
||
| 3019 | 3018 | */ |
| 3020 | 3019 | function weblog_ping($server = '', $path = '') { |
| 3021 | 3020 | global $wp_version; |
| 3022 | - include_once(ABSPATH . WPINC . '/class-IXR.php'); |
|
| 3023 | - include_once(ABSPATH . WPINC . '/class-wp-http-ixr-client.php'); |
|
| 3021 | + include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
| 3022 | + include_once(ABSPATH.WPINC.'/class-wp-http-ixr-client.php'); |
|
| 3024 | 3023 | |
| 3025 | 3024 | // using a timeout of 3 seconds should be enough to cover slow servers |
| 3026 | - $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); |
|
| 3025 | + $client = new WP_HTTP_IXR_Client($server, (( ! strlen(trim($path)) || ('/' == $path)) ? false : $path)); |
|
| 3027 | 3026 | $client->timeout = 3; |
| 3028 | 3027 | $client->useragent .= ' -- WordPress/'.$wp_version; |
| 3029 | 3028 | |
| 3030 | 3029 | // when set to true, this outputs debug messages by itself |
| 3031 | 3030 | $client->debug = false; |
| 3032 | - $home = trailingslashit( home_url() ); |
|
| 3033 | - if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping |
|
| 3031 | + $home = trailingslashit(home_url()); |
|
| 3032 | + if ( ! $client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url'))) // then try a normal ping |
|
| 3034 | 3033 | $client->query('weblogUpdates.ping', get_option('blogname'), $home); |
| 3035 | 3034 | } |
| 3036 | 3035 | |
@@ -3043,8 +3042,8 @@ discard block |
||
| 3043 | 3042 | * @param string $source_uri |
| 3044 | 3043 | * @return string |
| 3045 | 3044 | */ |
| 3046 | -function pingback_ping_source_uri( $source_uri ) { |
|
| 3047 | - return (string) wp_http_validate_url( $source_uri ); |
|
| 3045 | +function pingback_ping_source_uri($source_uri) { |
|
| 3046 | + return (string) wp_http_validate_url($source_uri); |
|
| 3048 | 3047 | } |
| 3049 | 3048 | |
| 3050 | 3049 | /** |
@@ -3059,10 +3058,10 @@ discard block |
||
| 3059 | 3058 | * @param IXR_Error $ixr_error |
| 3060 | 3059 | * @return IXR_Error |
| 3061 | 3060 | */ |
| 3062 | -function xmlrpc_pingback_error( $ixr_error ) { |
|
| 3063 | - if ( $ixr_error->code === 48 ) |
|
| 3061 | +function xmlrpc_pingback_error($ixr_error) { |
|
| 3062 | + if ($ixr_error->code === 48) |
|
| 3064 | 3063 | return $ixr_error; |
| 3065 | - return new IXR_Error( 0, '' ); |
|
| 3064 | + return new IXR_Error(0, ''); |
|
| 3066 | 3065 | } |
| 3067 | 3066 | |
| 3068 | 3067 | // |
@@ -3077,10 +3076,10 @@ discard block |
||
| 3077 | 3076 | * @param int|array $ids Comment ID or array of comment IDs to remove from cache |
| 3078 | 3077 | */ |
| 3079 | 3078 | function clean_comment_cache($ids) { |
| 3080 | - foreach ( (array) $ids as $id ) |
|
| 3079 | + foreach ((array) $ids as $id) |
|
| 3081 | 3080 | wp_cache_delete($id, 'comment'); |
| 3082 | 3081 | |
| 3083 | - wp_cache_set( 'last_changed', microtime(), 'comment' ); |
|
| 3082 | + wp_cache_set('last_changed', microtime(), 'comment'); |
|
| 3084 | 3083 | } |
| 3085 | 3084 | |
| 3086 | 3085 | /** |
@@ -3095,7 +3094,7 @@ discard block |
||
| 3095 | 3094 | * @param array $comments Array of comment row objects |
| 3096 | 3095 | */ |
| 3097 | 3096 | function update_comment_cache($comments) { |
| 3098 | - foreach ( (array) $comments as $comment ) |
|
| 3097 | + foreach ((array) $comments as $comment) |
|
| 3099 | 3098 | wp_cache_add($comment->comment_ID, $comment, 'comment'); |
| 3100 | 3099 | } |
| 3101 | 3100 | |
@@ -3113,8 +3112,8 @@ discard block |
||
| 3113 | 3112 | * @param WP_Query $query Query object. |
| 3114 | 3113 | * @return array |
| 3115 | 3114 | */ |
| 3116 | -function _close_comments_for_old_posts( $posts, $query ) { |
|
| 3117 | - if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
|
| 3115 | +function _close_comments_for_old_posts($posts, $query) { |
|
| 3116 | + if (empty($posts) || ! $query->is_singular() || ! get_option('close_comments_for_old_posts')) |
|
| 3118 | 3117 | return $posts; |
| 3119 | 3118 | |
| 3120 | 3119 | /** |
@@ -3124,15 +3123,15 @@ discard block |
||
| 3124 | 3123 | * |
| 3125 | 3124 | * @param array $post_types An array of registered post types. Default array with 'post'. |
| 3126 | 3125 | */ |
| 3127 | - $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
|
| 3128 | - if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
|
| 3126 | + $post_types = apply_filters('close_comments_for_post_types', array('post')); |
|
| 3127 | + if ( ! in_array($posts[0]->post_type, $post_types)) |
|
| 3129 | 3128 | return $posts; |
| 3130 | 3129 | |
| 3131 | - $days_old = (int) get_option( 'close_comments_days_old' ); |
|
| 3132 | - if ( ! $days_old ) |
|
| 3130 | + $days_old = (int) get_option('close_comments_days_old'); |
|
| 3131 | + if ( ! $days_old) |
|
| 3133 | 3132 | return $posts; |
| 3134 | 3133 | |
| 3135 | - if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
|
| 3134 | + if (time() - strtotime($posts[0]->post_date_gmt) > ($days_old * DAY_IN_SECONDS)) { |
|
| 3136 | 3135 | $posts[0]->comment_status = 'closed'; |
| 3137 | 3136 | $posts[0]->ping_status = 'closed'; |
| 3138 | 3137 | } |
@@ -3150,25 +3149,25 @@ discard block |
||
| 3150 | 3149 | * @param int $post_id Post ID |
| 3151 | 3150 | * @return bool $open |
| 3152 | 3151 | */ |
| 3153 | -function _close_comments_for_old_post( $open, $post_id ) { |
|
| 3154 | - if ( ! $open ) |
|
| 3152 | +function _close_comments_for_old_post($open, $post_id) { |
|
| 3153 | + if ( ! $open) |
|
| 3155 | 3154 | return $open; |
| 3156 | 3155 | |
| 3157 | - if ( !get_option('close_comments_for_old_posts') ) |
|
| 3156 | + if ( ! get_option('close_comments_for_old_posts')) |
|
| 3158 | 3157 | return $open; |
| 3159 | 3158 | |
| 3160 | 3159 | $days_old = (int) get_option('close_comments_days_old'); |
| 3161 | - if ( !$days_old ) |
|
| 3160 | + if ( ! $days_old) |
|
| 3162 | 3161 | return $open; |
| 3163 | 3162 | |
| 3164 | 3163 | $post = get_post($post_id); |
| 3165 | 3164 | |
| 3166 | 3165 | /** This filter is documented in wp-includes/comment.php */ |
| 3167 | - $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
|
| 3168 | - if ( ! in_array( $post->post_type, $post_types ) ) |
|
| 3166 | + $post_types = apply_filters('close_comments_for_post_types', array('post')); |
|
| 3167 | + if ( ! in_array($post->post_type, $post_types)) |
|
| 3169 | 3168 | return $open; |
| 3170 | 3169 | |
| 3171 | - if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |
|
| 3170 | + if (time() - strtotime($post->post_date_gmt) > ($days_old * DAY_IN_SECONDS)) |
|
| 3172 | 3171 | return false; |
| 3173 | 3172 | |
| 3174 | 3173 | return $open; |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | global $wpdb; |
| 41 | 41 | |
| 42 | 42 | // If manual moderation is enabled, skip all checks and return false. |
| 43 | - if ( 1 == get_option('comment_moderation') ) |
|
| 44 | - return false; |
|
| 43 | + if ( 1 == get_option('comment_moderation') ) { |
|
| 44 | + return false; |
|
| 45 | + } |
|
| 45 | 46 | |
| 46 | 47 | /** This filter is documented in wp-includes/comment-template.php */ |
| 47 | 48 | $comment = apply_filters( 'comment_text', $comment ); |
@@ -64,8 +65,9 @@ discard block |
||
| 64 | 65 | * If the number of links in the comment exceeds the allowed amount, |
| 65 | 66 | * fail the check by returning false. |
| 66 | 67 | */ |
| 67 | - if ( $num_links >= $max_links ) |
|
| 68 | - return false; |
|
| 68 | + if ( $num_links >= $max_links ) { |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | $mod_keys = trim(get_option('moderation_keys')); |
@@ -78,8 +80,9 @@ discard block |
||
| 78 | 80 | $word = trim($word); |
| 79 | 81 | |
| 80 | 82 | // Skip empty lines. |
| 81 | - if ( empty($word) ) |
|
| 82 | - continue; |
|
| 83 | + if ( empty($word) ) { |
|
| 84 | + continue; |
|
| 85 | + } |
|
| 83 | 86 | |
| 84 | 87 | /* |
| 85 | 88 | * Do some escaping magic so that '#' (number of) characters in the spam |
@@ -92,12 +95,24 @@ discard block |
||
| 92 | 95 | * fail the check for the given field by returning false. |
| 93 | 96 | */ |
| 94 | 97 | $pattern = "#$word#i"; |
| 95 | - if ( preg_match($pattern, $author) ) return false; |
|
| 96 | - if ( preg_match($pattern, $email) ) return false; |
|
| 97 | - if ( preg_match($pattern, $url) ) return false; |
|
| 98 | - if ( preg_match($pattern, $comment) ) return false; |
|
| 99 | - if ( preg_match($pattern, $user_ip) ) return false; |
|
| 100 | - if ( preg_match($pattern, $user_agent) ) return false; |
|
| 98 | + if ( preg_match($pattern, $author) ) { |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + if ( preg_match($pattern, $email) ) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | + if ( preg_match($pattern, $url) ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 107 | + if ( preg_match($pattern, $comment) ) { |
|
| 108 | + return false; |
|
| 109 | + } |
|
| 110 | + if ( preg_match($pattern, $user_ip) ) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + if ( preg_match($pattern, $user_agent) ) { |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 101 | 116 | } |
| 102 | 117 | } |
| 103 | 118 | |
@@ -113,10 +128,11 @@ discard block |
||
| 113 | 128 | // expected_slashed ($author, $email) |
| 114 | 129 | $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1"); |
| 115 | 130 | if ( ( 1 == $ok_to_comment ) && |
| 116 | - ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) |
|
| 117 | - return true; |
|
| 118 | - else |
|
| 119 | - return false; |
|
| 131 | + ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) ) { |
|
| 132 | + return true; |
|
| 133 | + } else { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 120 | 136 | } else { |
| 121 | 137 | return false; |
| 122 | 138 | } |
@@ -172,10 +188,11 @@ discard block |
||
| 172 | 188 | global $wpdb; |
| 173 | 189 | |
| 174 | 190 | if ( empty($comment) ) { |
| 175 | - if ( isset($GLOBALS['comment']) ) |
|
| 176 | - $_comment = & $GLOBALS['comment']; |
|
| 177 | - else |
|
| 178 | - $_comment = null; |
|
| 191 | + if ( isset($GLOBALS['comment']) ) { |
|
| 192 | + $_comment = & $GLOBALS['comment']; |
|
| 193 | + } else { |
|
| 194 | + $_comment = null; |
|
| 195 | + } |
|
| 179 | 196 | } elseif ( is_object($comment) ) { |
| 180 | 197 | wp_cache_add($comment->comment_ID, $comment, 'comment'); |
| 181 | 198 | $_comment = $comment; |
@@ -184,8 +201,9 @@ discard block |
||
| 184 | 201 | $_comment = & $GLOBALS['comment']; |
| 185 | 202 | } elseif ( ! $_comment = wp_cache_get($comment, 'comment') ) { |
| 186 | 203 | $_comment = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment)); |
| 187 | - if ( ! $_comment ) |
|
| 188 | - return null; |
|
| 204 | + if ( ! $_comment ) { |
|
| 205 | + return null; |
|
| 206 | + } |
|
| 189 | 207 | wp_cache_add($_comment->comment_ID, $_comment, 'comment'); |
| 190 | 208 | } |
| 191 | 209 | } |
@@ -1092,8 +1110,9 @@ discard block |
||
| 1092 | 1110 | global $wpdb; |
| 1093 | 1111 | static $cache_lastcommentmodified = array(); |
| 1094 | 1112 | |
| 1095 | - if ( isset($cache_lastcommentmodified[$timezone]) ) |
|
| 1096 | - return $cache_lastcommentmodified[$timezone]; |
|
| 1113 | + if ( isset($cache_lastcommentmodified[$timezone]) ) { |
|
| 1114 | + return $cache_lastcommentmodified[$timezone]; |
|
| 1115 | + } |
|
| 1097 | 1116 | |
| 1098 | 1117 | $add_seconds_server = date('Z'); |
| 1099 | 1118 | |
@@ -1260,8 +1279,9 @@ discard block |
||
| 1260 | 1279 | * @since 3.4.0 |
| 1261 | 1280 | */ |
| 1262 | 1281 | function wp_set_comment_cookies($comment, $user) { |
| 1263 | - if ( $user->exists() ) |
|
| 1264 | - return; |
|
| 1282 | + if ( $user->exists() ) { |
|
| 1283 | + return; |
|
| 1284 | + } |
|
| 1265 | 1285 | |
| 1266 | 1286 | /** |
| 1267 | 1287 | * Filter the lifetime of the comment cookie in seconds. |
@@ -1468,8 +1488,10 @@ discard block |
||
| 1468 | 1488 | */ |
| 1469 | 1489 | function check_comment_flood_db( $ip, $email, $date ) { |
| 1470 | 1490 | global $wpdb; |
| 1471 | - if ( current_user_can( 'manage_options' ) ) |
|
| 1472 | - return; // don't throttle admins |
|
| 1491 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 1492 | + return; |
|
| 1493 | + } |
|
| 1494 | + // don't throttle admins |
|
| 1473 | 1495 | $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); |
| 1474 | 1496 | if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) { |
| 1475 | 1497 | $time_lastcomment = mysql2date('U', $lasttime, false); |
@@ -1495,8 +1517,9 @@ discard block |
||
| 1495 | 1517 | */ |
| 1496 | 1518 | do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment ); |
| 1497 | 1519 | |
| 1498 | - if ( defined('DOING_AJAX') ) |
|
| 1499 | - die( __('You are posting comments too quickly. Slow down.') ); |
|
| 1520 | + if ( defined('DOING_AJAX') ) { |
|
| 1521 | + die( __('You are posting comments too quickly. Slow down.') ); |
|
| 1522 | + } |
|
| 1500 | 1523 | |
| 1501 | 1524 | wp_die( __( 'You are posting comments too quickly. Slow down.' ), 429 ); |
| 1502 | 1525 | } |
@@ -1516,11 +1539,13 @@ discard block |
||
| 1516 | 1539 | $count = count($comments); |
| 1517 | 1540 | for ( $i = 0; $i < $count; $i++ ) { |
| 1518 | 1541 | $type = $comments[$i]->comment_type; |
| 1519 | - if ( empty($type) ) |
|
| 1520 | - $type = 'comment'; |
|
| 1542 | + if ( empty($type) ) { |
|
| 1543 | + $type = 'comment'; |
|
| 1544 | + } |
|
| 1521 | 1545 | $comments_by_type[$type][] = &$comments[$i]; |
| 1522 | - if ( 'trackback' == $type || 'pingback' == $type ) |
|
| 1523 | - $comments_by_type['pings'][] = &$comments[$i]; |
|
| 1546 | + if ( 'trackback' == $type || 'pingback' == $type ) { |
|
| 1547 | + $comments_by_type['pings'][] = &$comments[$i]; |
|
| 1548 | + } |
|
| 1524 | 1549 | } |
| 1525 | 1550 | |
| 1526 | 1551 | return $comments_by_type; |
@@ -1543,27 +1568,35 @@ discard block |
||
| 1543 | 1568 | function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { |
| 1544 | 1569 | global $wp_query; |
| 1545 | 1570 | |
| 1546 | - if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) |
|
| 1547 | - return $wp_query->max_num_comment_pages; |
|
| 1571 | + if ( null === $comments && null === $per_page && null === $threaded && !empty($wp_query->max_num_comment_pages) ) { |
|
| 1572 | + return $wp_query->max_num_comment_pages; |
|
| 1573 | + } |
|
| 1548 | 1574 | |
| 1549 | - if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) |
|
| 1550 | - $comments = $wp_query->comments; |
|
| 1575 | + if ( ( ! $comments || ! is_array( $comments ) ) && ! empty( $wp_query->comments ) ) { |
|
| 1576 | + $comments = $wp_query->comments; |
|
| 1577 | + } |
|
| 1551 | 1578 | |
| 1552 | - if ( empty($comments) ) |
|
| 1553 | - return 0; |
|
| 1579 | + if ( empty($comments) ) { |
|
| 1580 | + return 0; |
|
| 1581 | + } |
|
| 1554 | 1582 | |
| 1555 | - if ( ! get_option( 'page_comments' ) ) |
|
| 1556 | - return 1; |
|
| 1583 | + if ( ! get_option( 'page_comments' ) ) { |
|
| 1584 | + return 1; |
|
| 1585 | + } |
|
| 1557 | 1586 | |
| 1558 | - if ( !isset($per_page) ) |
|
| 1559 | - $per_page = (int) get_query_var('comments_per_page'); |
|
| 1560 | - if ( 0 === $per_page ) |
|
| 1561 | - $per_page = (int) get_option('comments_per_page'); |
|
| 1562 | - if ( 0 === $per_page ) |
|
| 1563 | - return 1; |
|
| 1587 | + if ( !isset($per_page) ) { |
|
| 1588 | + $per_page = (int) get_query_var('comments_per_page'); |
|
| 1589 | + } |
|
| 1590 | + if ( 0 === $per_page ) { |
|
| 1591 | + $per_page = (int) get_option('comments_per_page'); |
|
| 1592 | + } |
|
| 1593 | + if ( 0 === $per_page ) { |
|
| 1594 | + return 1; |
|
| 1595 | + } |
|
| 1564 | 1596 | |
| 1565 | - if ( !isset($threaded) ) |
|
| 1566 | - $threaded = get_option('thread_comments'); |
|
| 1597 | + if ( !isset($threaded) ) { |
|
| 1598 | + $threaded = get_option('thread_comments'); |
|
| 1599 | + } |
|
| 1567 | 1600 | |
| 1568 | 1601 | if ( $threaded ) { |
| 1569 | 1602 | $walker = new Walker_Comment; |
@@ -1589,31 +1622,36 @@ discard block |
||
| 1589 | 1622 | function get_page_of_comment( $comment_ID, $args = array() ) { |
| 1590 | 1623 | global $wpdb; |
| 1591 | 1624 | |
| 1592 | - if ( !$comment = get_comment( $comment_ID ) ) |
|
| 1593 | - return; |
|
| 1625 | + if ( !$comment = get_comment( $comment_ID ) ) { |
|
| 1626 | + return; |
|
| 1627 | + } |
|
| 1594 | 1628 | |
| 1595 | 1629 | $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); |
| 1596 | 1630 | $args = wp_parse_args( $args, $defaults ); |
| 1597 | 1631 | |
| 1598 | - if ( '' === $args['per_page'] && get_option('page_comments') ) |
|
| 1599 | - $args['per_page'] = get_query_var('comments_per_page'); |
|
| 1632 | + if ( '' === $args['per_page'] && get_option('page_comments') ) { |
|
| 1633 | + $args['per_page'] = get_query_var('comments_per_page'); |
|
| 1634 | + } |
|
| 1600 | 1635 | if ( empty($args['per_page']) ) { |
| 1601 | 1636 | $args['per_page'] = 0; |
| 1602 | 1637 | $args['page'] = 0; |
| 1603 | 1638 | } |
| 1604 | - if ( $args['per_page'] < 1 ) |
|
| 1605 | - return 1; |
|
| 1639 | + if ( $args['per_page'] < 1 ) { |
|
| 1640 | + return 1; |
|
| 1641 | + } |
|
| 1606 | 1642 | |
| 1607 | 1643 | if ( '' === $args['max_depth'] ) { |
| 1608 | - if ( get_option('thread_comments') ) |
|
| 1609 | - $args['max_depth'] = get_option('thread_comments_depth'); |
|
| 1610 | - else |
|
| 1611 | - $args['max_depth'] = -1; |
|
| 1644 | + if ( get_option('thread_comments') ) { |
|
| 1645 | + $args['max_depth'] = get_option('thread_comments_depth'); |
|
| 1646 | + } else { |
|
| 1647 | + $args['max_depth'] = -1; |
|
| 1648 | + } |
|
| 1612 | 1649 | } |
| 1613 | 1650 | |
| 1614 | 1651 | // Find this comment's top level parent if threading is enabled |
| 1615 | - if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) |
|
| 1616 | - return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 1652 | + if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) { |
|
| 1653 | + return get_page_of_comment( $comment->comment_parent, $args ); |
|
| 1654 | + } |
|
| 1617 | 1655 | |
| 1618 | 1656 | $allowedtypes = array( |
| 1619 | 1657 | 'comment' => '', |
@@ -1627,8 +1665,9 @@ discard block |
||
| 1627 | 1665 | $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); |
| 1628 | 1666 | |
| 1629 | 1667 | // No older comments? Then it's page #1. |
| 1630 | - if ( 0 == $oldercoms ) |
|
| 1631 | - return 1; |
|
| 1668 | + if ( 0 == $oldercoms ) { |
|
| 1669 | + return 1; |
|
| 1670 | + } |
|
| 1632 | 1671 | |
| 1633 | 1672 | // Divide comments older than this one by comments per page to get this comment's page number |
| 1634 | 1673 | return ceil( ( $oldercoms + 1 ) / $args['per_page'] ); |
@@ -1663,8 +1702,10 @@ discard block |
||
| 1663 | 1702 | do_action( 'wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent ); |
| 1664 | 1703 | |
| 1665 | 1704 | $mod_keys = trim( get_option('blacklist_keys') ); |
| 1666 | - if ( '' == $mod_keys ) |
|
| 1667 | - return false; // If moderation keys are empty |
|
| 1705 | + if ( '' == $mod_keys ) { |
|
| 1706 | + return false; |
|
| 1707 | + } |
|
| 1708 | + // If moderation keys are empty |
|
| 1668 | 1709 | $words = explode("\n", $mod_keys ); |
| 1669 | 1710 | |
| 1670 | 1711 | foreach ( (array) $words as $word ) { |
@@ -1685,8 +1726,9 @@ discard block |
||
| 1685 | 1726 | || preg_match($pattern, $comment) |
| 1686 | 1727 | || preg_match($pattern, $user_ip) |
| 1687 | 1728 | || preg_match($pattern, $user_agent) |
| 1688 | - ) |
|
| 1689 | - return true; |
|
| 1729 | + ) { |
|
| 1730 | + return true; |
|
| 1731 | + } |
|
| 1690 | 1732 | } |
| 1691 | 1733 | return false; |
| 1692 | 1734 | } |
@@ -1723,17 +1765,20 @@ discard block |
||
| 1723 | 1765 | * @param int $post_id The post ID. |
| 1724 | 1766 | */ |
| 1725 | 1767 | $stats = apply_filters( 'wp_count_comments', array(), $post_id ); |
| 1726 | - if ( !empty($stats) ) |
|
| 1727 | - return $stats; |
|
| 1768 | + if ( !empty($stats) ) { |
|
| 1769 | + return $stats; |
|
| 1770 | + } |
|
| 1728 | 1771 | |
| 1729 | 1772 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
| 1730 | 1773 | |
| 1731 | - if ( false !== $count ) |
|
| 1732 | - return $count; |
|
| 1774 | + if ( false !== $count ) { |
|
| 1775 | + return $count; |
|
| 1776 | + } |
|
| 1733 | 1777 | |
| 1734 | 1778 | $where = ''; |
| 1735 | - if ( $post_id > 0 ) |
|
| 1736 | - $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id ); |
|
| 1779 | + if ( $post_id > 0 ) { |
|
| 1780 | + $where = $wpdb->prepare( "WHERE comment_post_ID = %d", $post_id ); |
|
| 1781 | + } |
|
| 1737 | 1782 | |
| 1738 | 1783 | $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
| 1739 | 1784 | |
@@ -1741,16 +1786,19 @@ discard block |
||
| 1741 | 1786 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
| 1742 | 1787 | foreach ( (array) $count as $row ) { |
| 1743 | 1788 | // Don't count post-trashed toward totals |
| 1744 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
| 1745 | - $total += $row['num_comments']; |
|
| 1746 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
| 1747 | - $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1789 | + if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
| 1790 | + $total += $row['num_comments']; |
|
| 1791 | + } |
|
| 1792 | + if ( isset( $approved[$row['comment_approved']] ) ) { |
|
| 1793 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1794 | + } |
|
| 1748 | 1795 | } |
| 1749 | 1796 | |
| 1750 | 1797 | $stats['total_comments'] = $total; |
| 1751 | 1798 | foreach ( $approved as $key ) { |
| 1752 | - if ( empty($stats[$key]) ) |
|
| 1753 | - $stats[$key] = 0; |
|
| 1799 | + if ( empty($stats[$key]) ) { |
|
| 1800 | + $stats[$key] = 0; |
|
| 1801 | + } |
|
| 1754 | 1802 | } |
| 1755 | 1803 | |
| 1756 | 1804 | $stats = (object) $stats; |
@@ -1778,11 +1826,13 @@ discard block |
||
| 1778 | 1826 | */ |
| 1779 | 1827 | function wp_delete_comment($comment_id, $force_delete = false) { |
| 1780 | 1828 | global $wpdb; |
| 1781 | - if (!$comment = get_comment($comment_id)) |
|
| 1782 | - return false; |
|
| 1829 | + if (!$comment = get_comment($comment_id)) { |
|
| 1830 | + return false; |
|
| 1831 | + } |
|
| 1783 | 1832 | |
| 1784 | - if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) ) |
|
| 1785 | - return wp_trash_comment($comment_id); |
|
| 1833 | + if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status($comment_id), array( 'trash', 'spam' ) ) ) { |
|
| 1834 | + return wp_trash_comment($comment_id); |
|
| 1835 | + } |
|
| 1786 | 1836 | |
| 1787 | 1837 | /** |
| 1788 | 1838 | * Fires immediately before a comment is deleted from the database. |
@@ -1802,11 +1852,13 @@ discard block |
||
| 1802 | 1852 | |
| 1803 | 1853 | // Delete metadata |
| 1804 | 1854 | $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment_id ) ); |
| 1805 | - foreach ( $meta_ids as $mid ) |
|
| 1806 | - delete_metadata_by_mid( 'comment', $mid ); |
|
| 1855 | + foreach ( $meta_ids as $mid ) { |
|
| 1856 | + delete_metadata_by_mid( 'comment', $mid ); |
|
| 1857 | + } |
|
| 1807 | 1858 | |
| 1808 | - if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) |
|
| 1809 | - return false; |
|
| 1859 | + if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment_id ) ) ) { |
|
| 1860 | + return false; |
|
| 1861 | + } |
|
| 1810 | 1862 | |
| 1811 | 1863 | /** |
| 1812 | 1864 | * Fires immediately after a comment is deleted from the database. |
@@ -1818,8 +1870,9 @@ discard block |
||
| 1818 | 1870 | do_action( 'deleted_comment', $comment_id ); |
| 1819 | 1871 | |
| 1820 | 1872 | $post_id = $comment->comment_post_ID; |
| 1821 | - if ( $post_id && $comment->comment_approved == 1 ) |
|
| 1822 | - wp_update_comment_count($post_id); |
|
| 1873 | + if ( $post_id && $comment->comment_approved == 1 ) { |
|
| 1874 | + wp_update_comment_count($post_id); |
|
| 1875 | + } |
|
| 1823 | 1876 | |
| 1824 | 1877 | clean_comment_cache($comment_id); |
| 1825 | 1878 | |
@@ -1841,11 +1894,13 @@ discard block |
||
| 1841 | 1894 | * @return bool True on success, false on failure. |
| 1842 | 1895 | */ |
| 1843 | 1896 | function wp_trash_comment($comment_id) { |
| 1844 | - if ( !EMPTY_TRASH_DAYS ) |
|
| 1845 | - return wp_delete_comment($comment_id, true); |
|
| 1897 | + if ( !EMPTY_TRASH_DAYS ) { |
|
| 1898 | + return wp_delete_comment($comment_id, true); |
|
| 1899 | + } |
|
| 1846 | 1900 | |
| 1847 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1848 | - return false; |
|
| 1901 | + if ( !$comment = get_comment($comment_id) ) { |
|
| 1902 | + return false; |
|
| 1903 | + } |
|
| 1849 | 1904 | |
| 1850 | 1905 | /** |
| 1851 | 1906 | * Fires immediately before a comment is sent to the Trash. |
@@ -1885,8 +1940,9 @@ discard block |
||
| 1885 | 1940 | * @return bool True on success, false on failure. |
| 1886 | 1941 | */ |
| 1887 | 1942 | function wp_untrash_comment($comment_id) { |
| 1888 | - if ( ! (int)$comment_id ) |
|
| 1889 | - return false; |
|
| 1943 | + if ( ! (int)$comment_id ) { |
|
| 1944 | + return false; |
|
| 1945 | + } |
|
| 1890 | 1946 | |
| 1891 | 1947 | /** |
| 1892 | 1948 | * Fires immediately before a comment is restored from the Trash. |
@@ -1898,8 +1954,9 @@ discard block |
||
| 1898 | 1954 | do_action( 'untrash_comment', $comment_id ); |
| 1899 | 1955 | |
| 1900 | 1956 | $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); |
| 1901 | - if ( empty($status) ) |
|
| 1902 | - $status = '0'; |
|
| 1957 | + if ( empty($status) ) { |
|
| 1958 | + $status = '0'; |
|
| 1959 | + } |
|
| 1903 | 1960 | |
| 1904 | 1961 | if ( wp_set_comment_status($comment_id, $status) ) { |
| 1905 | 1962 | delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
@@ -1927,8 +1984,9 @@ discard block |
||
| 1927 | 1984 | * @return bool True on success, false on failure. |
| 1928 | 1985 | */ |
| 1929 | 1986 | function wp_spam_comment($comment_id) { |
| 1930 | - if ( !$comment = get_comment($comment_id) ) |
|
| 1931 | - return false; |
|
| 1987 | + if ( !$comment = get_comment($comment_id) ) { |
|
| 1988 | + return false; |
|
| 1989 | + } |
|
| 1932 | 1990 | |
| 1933 | 1991 | /** |
| 1934 | 1992 | * Fires immediately before a comment is marked as Spam. |
@@ -1967,8 +2025,9 @@ discard block |
||
| 1967 | 2025 | * @return bool True on success, false on failure. |
| 1968 | 2026 | */ |
| 1969 | 2027 | function wp_unspam_comment($comment_id) { |
| 1970 | - if ( ! (int)$comment_id ) |
|
| 1971 | - return false; |
|
| 2028 | + if ( ! (int)$comment_id ) { |
|
| 2029 | + return false; |
|
| 2030 | + } |
|
| 1972 | 2031 | |
| 1973 | 2032 | /** |
| 1974 | 2033 | * Fires immediately before a comment is unmarked as Spam. |
@@ -1980,8 +2039,9 @@ discard block |
||
| 1980 | 2039 | do_action( 'unspam_comment', $comment_id ); |
| 1981 | 2040 | |
| 1982 | 2041 | $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); |
| 1983 | - if ( empty($status) ) |
|
| 1984 | - $status = '0'; |
|
| 2042 | + if ( empty($status) ) { |
|
| 2043 | + $status = '0'; |
|
| 2044 | + } |
|
| 1985 | 2045 | |
| 1986 | 2046 | if ( wp_set_comment_status($comment_id, $status) ) { |
| 1987 | 2047 | delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); |
@@ -2010,24 +2070,26 @@ discard block |
||
| 2010 | 2070 | */ |
| 2011 | 2071 | function wp_get_comment_status($comment_id) { |
| 2012 | 2072 | $comment = get_comment($comment_id); |
| 2013 | - if ( !$comment ) |
|
| 2014 | - return false; |
|
| 2073 | + if ( !$comment ) { |
|
| 2074 | + return false; |
|
| 2075 | + } |
|
| 2015 | 2076 | |
| 2016 | 2077 | $approved = $comment->comment_approved; |
| 2017 | 2078 | |
| 2018 | - if ( $approved == null ) |
|
| 2019 | - return false; |
|
| 2020 | - elseif ( $approved == '1' ) |
|
| 2021 | - return 'approved'; |
|
| 2022 | - elseif ( $approved == '0' ) |
|
| 2023 | - return 'unapproved'; |
|
| 2024 | - elseif ( $approved == 'spam' ) |
|
| 2025 | - return 'spam'; |
|
| 2026 | - elseif ( $approved == 'trash' ) |
|
| 2027 | - return 'trash'; |
|
| 2028 | - else |
|
| 2029 | - return false; |
|
| 2030 | -} |
|
| 2079 | + if ( $approved == null ) { |
|
| 2080 | + return false; |
|
| 2081 | + } elseif ( $approved == '1' ) { |
|
| 2082 | + return 'approved'; |
|
| 2083 | + } elseif ( $approved == '0' ) { |
|
| 2084 | + return 'unapproved'; |
|
| 2085 | + } elseif ( $approved == 'spam' ) { |
|
| 2086 | + return 'spam'; |
|
| 2087 | + } elseif ( $approved == 'trash' ) { |
|
| 2088 | + return 'trash'; |
|
| 2089 | + } else { |
|
| 2090 | + return false; |
|
| 2091 | + } |
|
| 2092 | + } |
|
| 2031 | 2093 | |
| 2032 | 2094 | /** |
| 2033 | 2095 | * Call hooks for when a comment status transition occurs. |
@@ -2061,8 +2123,12 @@ discard block |
||
| 2061 | 2123 | 1 => 'approved', |
| 2062 | 2124 | 'approve' => 'approved', // wp_set_comment_status() uses "approve" |
| 2063 | 2125 | ); |
| 2064 | - if ( isset($comment_statuses[$new_status]) ) $new_status = $comment_statuses[$new_status]; |
|
| 2065 | - if ( isset($comment_statuses[$old_status]) ) $old_status = $comment_statuses[$old_status]; |
|
| 2126 | + if ( isset($comment_statuses[$new_status]) ) { |
|
| 2127 | + $new_status = $comment_statuses[$new_status]; |
|
| 2128 | + } |
|
| 2129 | + if ( isset($comment_statuses[$old_status]) ) { |
|
| 2130 | + $old_status = $comment_statuses[$old_status]; |
|
| 2131 | + } |
|
| 2066 | 2132 | |
| 2067 | 2133 | // Call the hooks |
| 2068 | 2134 | if ( $new_status != $old_status ) { |
@@ -2121,16 +2187,19 @@ discard block |
||
| 2121 | 2187 | // Cookies should already be sanitized. |
| 2122 | 2188 | |
| 2123 | 2189 | $comment_author = ''; |
| 2124 | - if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) |
|
| 2125 | - $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
|
| 2190 | + if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) ) { |
|
| 2191 | + $comment_author = $_COOKIE['comment_author_'.COOKIEHASH]; |
|
| 2192 | + } |
|
| 2126 | 2193 | |
| 2127 | 2194 | $comment_author_email = ''; |
| 2128 | - if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) |
|
| 2129 | - $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
|
| 2195 | + if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) { |
|
| 2196 | + $comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH]; |
|
| 2197 | + } |
|
| 2130 | 2198 | |
| 2131 | 2199 | $comment_author_url = ''; |
| 2132 | - if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) |
|
| 2133 | - $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
|
| 2200 | + if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ) { |
|
| 2201 | + $comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH]; |
|
| 2202 | + } |
|
| 2134 | 2203 | |
| 2135 | 2204 | /** |
| 2136 | 2205 | * Filter the current commenter's name, email, and URL. |
@@ -2300,10 +2369,13 @@ discard block |
||
| 2300 | 2369 | * @return bool Whether comment should be blocked. |
| 2301 | 2370 | */ |
| 2302 | 2371 | function wp_throttle_comment_flood($block, $time_lastcomment, $time_newcomment) { |
| 2303 | - if ( $block ) // a plugin has already blocked... we'll let that decision stand |
|
| 2372 | + if ( $block ) { |
|
| 2373 | + // a plugin has already blocked... we'll let that decision stand |
|
| 2304 | 2374 | return $block; |
| 2305 | - if ( ($time_newcomment - $time_lastcomment) < 15 ) |
|
| 2306 | - return true; |
|
| 2375 | + } |
|
| 2376 | + if ( ($time_newcomment - $time_lastcomment) < 15 ) { |
|
| 2377 | + return true; |
|
| 2378 | + } |
|
| 2307 | 2379 | return false; |
| 2308 | 2380 | } |
| 2309 | 2381 | |
@@ -2469,10 +2541,11 @@ discard block |
||
| 2469 | 2541 | $comment_old = clone get_comment($comment_id); |
| 2470 | 2542 | |
| 2471 | 2543 | if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id) ) ) { |
| 2472 | - if ( $wp_error ) |
|
| 2473 | - return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
|
| 2474 | - else |
|
| 2475 | - return false; |
|
| 2544 | + if ( $wp_error ) { |
|
| 2545 | + return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); |
|
| 2546 | + } else { |
|
| 2547 | + return false; |
|
| 2548 | + } |
|
| 2476 | 2549 | } |
| 2477 | 2550 | |
| 2478 | 2551 | clean_comment_cache($comment_id); |
@@ -2599,8 +2672,9 @@ discard block |
||
| 2599 | 2672 | if ( is_bool($defer) ) { |
| 2600 | 2673 | $_defer = $defer; |
| 2601 | 2674 | // flush any deferred counts |
| 2602 | - if ( !$defer ) |
|
| 2603 | - wp_update_comment_count( null, true ); |
|
| 2675 | + if ( !$defer ) { |
|
| 2676 | + wp_update_comment_count( null, true ); |
|
| 2677 | + } |
|
| 2604 | 2678 | } |
| 2605 | 2679 | |
| 2606 | 2680 | return $_defer; |
@@ -2640,8 +2714,7 @@ discard block |
||
| 2640 | 2714 | if ( wp_defer_comment_counting() ) { |
| 2641 | 2715 | $_deferred[] = $post_id; |
| 2642 | 2716 | return true; |
| 2643 | - } |
|
| 2644 | - elseif ( $post_id ) { |
|
| 2717 | + } elseif ( $post_id ) { |
|
| 2645 | 2718 | return wp_update_comment_count_now($post_id); |
| 2646 | 2719 | } |
| 2647 | 2720 | |
@@ -2660,10 +2733,12 @@ discard block |
||
| 2660 | 2733 | function wp_update_comment_count_now($post_id) { |
| 2661 | 2734 | global $wpdb; |
| 2662 | 2735 | $post_id = (int) $post_id; |
| 2663 | - if ( !$post_id ) |
|
| 2664 | - return false; |
|
| 2665 | - if ( !$post = get_post($post_id) ) |
|
| 2666 | - return false; |
|
| 2736 | + if ( !$post_id ) { |
|
| 2737 | + return false; |
|
| 2738 | + } |
|
| 2739 | + if ( !$post = get_post($post_id) ) { |
|
| 2740 | + return false; |
|
| 2741 | + } |
|
| 2667 | 2742 | |
| 2668 | 2743 | $old = (int) $post->comment_count; |
| 2669 | 2744 | $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) ); |
@@ -2705,8 +2780,9 @@ discard block |
||
| 2705 | 2780 | * @return false|string False on failure, string containing URI on success. |
| 2706 | 2781 | */ |
| 2707 | 2782 | function discover_pingback_server_uri( $url, $deprecated = '' ) { |
| 2708 | - if ( !empty( $deprecated ) ) |
|
| 2709 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2783 | + if ( !empty( $deprecated ) ) { |
|
| 2784 | + _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 2785 | + } |
|
| 2710 | 2786 | |
| 2711 | 2787 | $pingback_str_dquote = 'rel="pingback"'; |
| 2712 | 2788 | $pingback_str_squote = 'rel=\'pingback\''; |
@@ -2714,31 +2790,38 @@ discard block |
||
| 2714 | 2790 | /** @todo Should use Filter Extension or custom preg_match instead. */ |
| 2715 | 2791 | $parsed_url = parse_url($url); |
| 2716 | 2792 | |
| 2717 | - if ( ! isset( $parsed_url['host'] ) ) // Not an URL. This should never happen. |
|
| 2793 | + if ( ! isset( $parsed_url['host'] ) ) { |
|
| 2794 | + // Not an URL. This should never happen. |
|
| 2718 | 2795 | return false; |
| 2796 | + } |
|
| 2719 | 2797 | |
| 2720 | 2798 | //Do not search for a pingback server on our own uploads |
| 2721 | 2799 | $uploads_dir = wp_upload_dir(); |
| 2722 | - if ( 0 === strpos($url, $uploads_dir['baseurl']) ) |
|
| 2723 | - return false; |
|
| 2800 | + if ( 0 === strpos($url, $uploads_dir['baseurl']) ) { |
|
| 2801 | + return false; |
|
| 2802 | + } |
|
| 2724 | 2803 | |
| 2725 | 2804 | $response = wp_safe_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
| 2726 | 2805 | |
| 2727 | - if ( is_wp_error( $response ) ) |
|
| 2728 | - return false; |
|
| 2806 | + if ( is_wp_error( $response ) ) { |
|
| 2807 | + return false; |
|
| 2808 | + } |
|
| 2729 | 2809 | |
| 2730 | - if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) |
|
| 2731 | - return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2810 | + if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) { |
|
| 2811 | + return wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 2812 | + } |
|
| 2732 | 2813 | |
| 2733 | 2814 | // Not an (x)html, sgml, or xml page, no use going further. |
| 2734 | - if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) |
|
| 2735 | - return false; |
|
| 2815 | + if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) { |
|
| 2816 | + return false; |
|
| 2817 | + } |
|
| 2736 | 2818 | |
| 2737 | 2819 | // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) |
| 2738 | 2820 | $response = wp_safe_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) ); |
| 2739 | 2821 | |
| 2740 | - if ( is_wp_error( $response ) ) |
|
| 2741 | - return false; |
|
| 2822 | + if ( is_wp_error( $response ) ) { |
|
| 2823 | + return false; |
|
| 2824 | + } |
|
| 2742 | 2825 | |
| 2743 | 2826 | $contents = wp_remote_retrieve_body( $response ); |
| 2744 | 2827 | |
@@ -2786,9 +2869,10 @@ discard block |
||
| 2786 | 2869 | |
| 2787 | 2870 | // Do Trackbacks |
| 2788 | 2871 | $trackbacks = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE to_ping <> '' AND post_status = 'publish'"); |
| 2789 | - if ( is_array($trackbacks) ) |
|
| 2790 | - foreach ( $trackbacks as $trackback ) |
|
| 2872 | + if ( is_array($trackbacks) ) { |
|
| 2873 | + foreach ( $trackbacks as $trackback ) |
|
| 2791 | 2874 | do_trackbacks($trackback); |
| 2875 | + } |
|
| 2792 | 2876 | |
| 2793 | 2877 | //Do Update Services/Generic Pings |
| 2794 | 2878 | generic_ping(); |
@@ -2856,8 +2940,9 @@ discard block |
||
| 2856 | 2940 | $services = explode("\n", $services); |
| 2857 | 2941 | foreach ( (array) $services as $service ) { |
| 2858 | 2942 | $service = trim($service); |
| 2859 | - if ( '' != $service ) |
|
| 2860 | - weblog_ping($service); |
|
| 2943 | + if ( '' != $service ) { |
|
| 2944 | + weblog_ping($service); |
|
| 2945 | + } |
|
| 2861 | 2946 | } |
| 2862 | 2947 | |
| 2863 | 2948 | return $post_id; |
@@ -2900,10 +2985,11 @@ discard block |
||
| 2900 | 2985 | if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself |
| 2901 | 2986 | && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments. |
| 2902 | 2987 | if ( $test = @parse_url($link_test) ) { |
| 2903 | - if ( isset($test['query']) ) |
|
| 2904 | - $post_links[] = $link_test; |
|
| 2905 | - elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) |
|
| 2906 | - $post_links[] = $link_test; |
|
| 2988 | + if ( isset($test['query']) ) { |
|
| 2989 | + $post_links[] = $link_test; |
|
| 2990 | + } elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) { |
|
| 2991 | + $post_links[] = $link_test; |
|
| 2992 | + } |
|
| 2907 | 2993 | } |
| 2908 | 2994 | endif; |
| 2909 | 2995 | endforeach; |
@@ -2947,8 +3033,10 @@ discard block |
||
| 2947 | 3033 | // when set to true, this outputs debug messages by itself |
| 2948 | 3034 | $client->debug = false; |
| 2949 | 3035 | |
| 2950 | - if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) // Already registered |
|
| 3036 | + if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto) || ( isset($client->error->code) && 48 == $client->error->code ) ) { |
|
| 3037 | + // Already registered |
|
| 2951 | 3038 | add_ping( $post_ID, $pagelinkedto ); |
| 3039 | + } |
|
| 2952 | 3040 | } |
| 2953 | 3041 | } |
| 2954 | 3042 | } |
@@ -2962,11 +3050,12 @@ discard block |
||
| 2962 | 3050 | * @return mixed Empty string if blog is not public, returns $sites, if site is public. |
| 2963 | 3051 | */ |
| 2964 | 3052 | function privacy_ping_filter($sites) { |
| 2965 | - if ( '0' != get_option('blog_public') ) |
|
| 2966 | - return $sites; |
|
| 2967 | - else |
|
| 2968 | - return ''; |
|
| 2969 | -} |
|
| 3053 | + if ( '0' != get_option('blog_public') ) { |
|
| 3054 | + return $sites; |
|
| 3055 | + } else { |
|
| 3056 | + return ''; |
|
| 3057 | + } |
|
| 3058 | + } |
|
| 2970 | 3059 | |
| 2971 | 3060 | /** |
| 2972 | 3061 | * Send a Trackback. |
@@ -2986,8 +3075,9 @@ discard block |
||
| 2986 | 3075 | function trackback($trackback_url, $title, $excerpt, $ID) { |
| 2987 | 3076 | global $wpdb; |
| 2988 | 3077 | |
| 2989 | - if ( empty($trackback_url) ) |
|
| 2990 | - return; |
|
| 3078 | + if ( empty($trackback_url) ) { |
|
| 3079 | + return; |
|
| 3080 | + } |
|
| 2991 | 3081 | |
| 2992 | 3082 | $options = array(); |
| 2993 | 3083 | $options['timeout'] = 4; |
@@ -3000,8 +3090,9 @@ discard block |
||
| 3000 | 3090 | |
| 3001 | 3091 | $response = wp_safe_remote_post( $trackback_url, $options ); |
| 3002 | 3092 | |
| 3003 | - if ( is_wp_error( $response ) ) |
|
| 3004 | - return; |
|
| 3093 | + if ( is_wp_error( $response ) ) { |
|
| 3094 | + return; |
|
| 3095 | + } |
|
| 3005 | 3096 | |
| 3006 | 3097 | $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID) ); |
| 3007 | 3098 | return $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID) ); |
@@ -3030,9 +3121,11 @@ discard block |
||
| 3030 | 3121 | // when set to true, this outputs debug messages by itself |
| 3031 | 3122 | $client->debug = false; |
| 3032 | 3123 | $home = trailingslashit( home_url() ); |
| 3033 | - if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping |
|
| 3124 | + if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) { |
|
| 3125 | + // then try a normal ping |
|
| 3034 | 3126 | $client->query('weblogUpdates.ping', get_option('blogname'), $home); |
| 3035 | -} |
|
| 3127 | + } |
|
| 3128 | + } |
|
| 3036 | 3129 | |
| 3037 | 3130 | /** |
| 3038 | 3131 | * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI |
@@ -3060,8 +3153,9 @@ discard block |
||
| 3060 | 3153 | * @return IXR_Error |
| 3061 | 3154 | */ |
| 3062 | 3155 | function xmlrpc_pingback_error( $ixr_error ) { |
| 3063 | - if ( $ixr_error->code === 48 ) |
|
| 3064 | - return $ixr_error; |
|
| 3156 | + if ( $ixr_error->code === 48 ) { |
|
| 3157 | + return $ixr_error; |
|
| 3158 | + } |
|
| 3065 | 3159 | return new IXR_Error( 0, '' ); |
| 3066 | 3160 | } |
| 3067 | 3161 | |
@@ -3077,8 +3171,9 @@ discard block |
||
| 3077 | 3171 | * @param int|array $ids Comment ID or array of comment IDs to remove from cache |
| 3078 | 3172 | */ |
| 3079 | 3173 | function clean_comment_cache($ids) { |
| 3080 | - foreach ( (array) $ids as $id ) |
|
| 3081 | - wp_cache_delete($id, 'comment'); |
|
| 3174 | + foreach ( (array) $ids as $id ) { |
|
| 3175 | + wp_cache_delete($id, 'comment'); |
|
| 3176 | + } |
|
| 3082 | 3177 | |
| 3083 | 3178 | wp_cache_set( 'last_changed', microtime(), 'comment' ); |
| 3084 | 3179 | } |
@@ -3095,9 +3190,10 @@ discard block |
||
| 3095 | 3190 | * @param array $comments Array of comment row objects |
| 3096 | 3191 | */ |
| 3097 | 3192 | function update_comment_cache($comments) { |
| 3098 | - foreach ( (array) $comments as $comment ) |
|
| 3099 | - wp_cache_add($comment->comment_ID, $comment, 'comment'); |
|
| 3100 | -} |
|
| 3193 | + foreach ( (array) $comments as $comment ) { |
|
| 3194 | + wp_cache_add($comment->comment_ID, $comment, 'comment'); |
|
| 3195 | + } |
|
| 3196 | + } |
|
| 3101 | 3197 | |
| 3102 | 3198 | // |
| 3103 | 3199 | // Internal |
@@ -3114,8 +3210,9 @@ discard block |
||
| 3114 | 3210 | * @return array |
| 3115 | 3211 | */ |
| 3116 | 3212 | function _close_comments_for_old_posts( $posts, $query ) { |
| 3117 | - if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) |
|
| 3118 | - return $posts; |
|
| 3213 | + if ( empty( $posts ) || ! $query->is_singular() || ! get_option( 'close_comments_for_old_posts' ) ) { |
|
| 3214 | + return $posts; |
|
| 3215 | + } |
|
| 3119 | 3216 | |
| 3120 | 3217 | /** |
| 3121 | 3218 | * Filter the list of post types to automatically close comments for. |
@@ -3125,12 +3222,14 @@ discard block |
||
| 3125 | 3222 | * @param array $post_types An array of registered post types. Default array with 'post'. |
| 3126 | 3223 | */ |
| 3127 | 3224 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 3128 | - if ( ! in_array( $posts[0]->post_type, $post_types ) ) |
|
| 3129 | - return $posts; |
|
| 3225 | + if ( ! in_array( $posts[0]->post_type, $post_types ) ) { |
|
| 3226 | + return $posts; |
|
| 3227 | + } |
|
| 3130 | 3228 | |
| 3131 | 3229 | $days_old = (int) get_option( 'close_comments_days_old' ); |
| 3132 | - if ( ! $days_old ) |
|
| 3133 | - return $posts; |
|
| 3230 | + if ( ! $days_old ) { |
|
| 3231 | + return $posts; |
|
| 3232 | + } |
|
| 3134 | 3233 | |
| 3135 | 3234 | if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
| 3136 | 3235 | $posts[0]->comment_status = 'closed'; |
@@ -3151,25 +3250,30 @@ discard block |
||
| 3151 | 3250 | * @return bool $open |
| 3152 | 3251 | */ |
| 3153 | 3252 | function _close_comments_for_old_post( $open, $post_id ) { |
| 3154 | - if ( ! $open ) |
|
| 3155 | - return $open; |
|
| 3253 | + if ( ! $open ) { |
|
| 3254 | + return $open; |
|
| 3255 | + } |
|
| 3156 | 3256 | |
| 3157 | - if ( !get_option('close_comments_for_old_posts') ) |
|
| 3158 | - return $open; |
|
| 3257 | + if ( !get_option('close_comments_for_old_posts') ) { |
|
| 3258 | + return $open; |
|
| 3259 | + } |
|
| 3159 | 3260 | |
| 3160 | 3261 | $days_old = (int) get_option('close_comments_days_old'); |
| 3161 | - if ( !$days_old ) |
|
| 3162 | - return $open; |
|
| 3262 | + if ( !$days_old ) { |
|
| 3263 | + return $open; |
|
| 3264 | + } |
|
| 3163 | 3265 | |
| 3164 | 3266 | $post = get_post($post_id); |
| 3165 | 3267 | |
| 3166 | 3268 | /** This filter is documented in wp-includes/comment.php */ |
| 3167 | 3269 | $post_types = apply_filters( 'close_comments_for_post_types', array( 'post' ) ); |
| 3168 | - if ( ! in_array( $post->post_type, $post_types ) ) |
|
| 3169 | - return $open; |
|
| 3270 | + if ( ! in_array( $post->post_type, $post_types ) ) { |
|
| 3271 | + return $open; |
|
| 3272 | + } |
|
| 3170 | 3273 | |
| 3171 | - if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) |
|
| 3172 | - return false; |
|
| 3274 | + if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) { |
|
| 3275 | + return false; |
|
| 3276 | + } |
|
| 3173 | 3277 | |
| 3174 | 3278 | return $open; |
| 3175 | 3279 | } |
@@ -8,6 +8,10 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | // If gettext isn't available |
| 10 | 10 | if ( !function_exists('_') ) { |
| 11 | + |
|
| 12 | + /** |
|
| 13 | + * @param string $string |
|
| 14 | + */ |
|
| 11 | 15 | function _($string) { |
| 12 | 16 | return $string; |
| 13 | 17 | } |
@@ -42,6 +46,10 @@ discard block |
||
| 42 | 46 | } |
| 43 | 47 | |
| 44 | 48 | if ( ! function_exists( 'mb_substr' ) ) : |
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @param string $encoding |
|
| 52 | + */ |
|
| 45 | 53 | function mb_substr( $str, $start, $length = null, $encoding = null ) { |
| 46 | 54 | return _mb_substr( $str, $start, $length, $encoding ); |
| 47 | 55 | } |
@@ -97,6 +105,10 @@ discard block |
||
| 97 | 105 | } |
| 98 | 106 | |
| 99 | 107 | if ( ! function_exists( 'mb_strlen' ) ) : |
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @param string $encoding |
|
| 111 | + */ |
|
| 100 | 112 | function mb_strlen( $str, $encoding = null ) { |
| 101 | 113 | return _mb_strlen( $str, $encoding ); |
| 102 | 114 | } |
@@ -153,6 +165,12 @@ discard block |
||
| 153 | 165 | } |
| 154 | 166 | |
| 155 | 167 | if ( !function_exists('hash_hmac') ): |
| 168 | +/** |
|
| 169 | + * @param string $algo |
|
| 170 | + * @param string $data |
|
| 171 | + * |
|
| 172 | + * @return string |
|
| 173 | + */ |
|
| 156 | 174 | function hash_hmac($algo, $data, $key, $raw_output = false) { |
| 157 | 175 | return _hash_hmac($algo, $data, $key, $raw_output); |
| 158 | 176 | } |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress implementation for PHP functions either missing from older PHP versions or not included by default. |
|
| 4 | - * |
|
| 5 | - * @package PHP |
|
| 6 | - * @access private |
|
| 7 | - */ |
|
| 3 | + * WordPress implementation for PHP functions either missing from older PHP versions or not included by default. |
|
| 4 | + * |
|
| 5 | + * @package PHP |
|
| 6 | + * @access private |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | // If gettext isn't available |
| 10 | 10 | if ( !function_exists('_') ) { |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // If gettext isn't available |
| 10 | -if ( !function_exists('_') ) { |
|
| 10 | +if ( ! function_exists('_')) { |
|
| 11 | 11 | function _($string) { |
| 12 | 12 | return $string; |
| 13 | 13 | } |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * false : Used for testing - return false for future calls to this function |
| 28 | 28 | * 'reset': Used for testing - restore default behavior of this function |
| 29 | 29 | */ |
| 30 | -function _wp_can_use_pcre_u( $set = null ) { |
|
| 30 | +function _wp_can_use_pcre_u($set = null) { |
|
| 31 | 31 | static $utf8_pcre = 'reset'; |
| 32 | 32 | |
| 33 | - if ( null !== $set ) { |
|
| 33 | + if (null !== $set) { |
|
| 34 | 34 | $utf8_pcre = $set; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if ( 'reset' === $utf8_pcre ) { |
|
| 38 | - $utf8_pcre = @preg_match( '/^./u', 'a' ); |
|
| 37 | + if ('reset' === $utf8_pcre) { |
|
| 38 | + $utf8_pcre = @preg_match('/^./u', 'a'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $utf8_pcre; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | -if ( ! function_exists( 'mb_substr' ) ) : |
|
| 45 | - function mb_substr( $str, $start, $length = null, $encoding = null ) { |
|
| 46 | - return _mb_substr( $str, $start, $length, $encoding ); |
|
| 44 | +if ( ! function_exists('mb_substr')) : |
|
| 45 | + function mb_substr($str, $start, $length = null, $encoding = null) { |
|
| 46 | + return _mb_substr($str, $start, $length, $encoding); |
|
| 47 | 47 | } |
| 48 | 48 | endif; |
| 49 | 49 | |
@@ -52,22 +52,22 @@ discard block |
||
| 52 | 52 | * For $encoding === UTF-8, the $str input is expected to be a valid UTF-8 byte sequence. |
| 53 | 53 | * The behavior of this function for invalid inputs is undefined. |
| 54 | 54 | */ |
| 55 | -function _mb_substr( $str, $start, $length = null, $encoding = null ) { |
|
| 56 | - if ( null === $encoding ) { |
|
| 57 | - $encoding = get_option( 'blog_charset' ); |
|
| 55 | +function _mb_substr($str, $start, $length = null, $encoding = null) { |
|
| 56 | + if (null === $encoding) { |
|
| 57 | + $encoding = get_option('blog_charset'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // The solution below works only for UTF-8, |
| 61 | 61 | // so in case of a different charset just use built-in substr() |
| 62 | - if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { |
|
| 63 | - return is_null( $length ) ? substr( $str, $start ) : substr( $str, $start, $length ); |
|
| 62 | + if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) { |
|
| 63 | + return is_null($length) ? substr($str, $start) : substr($str, $start, $length); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( _wp_can_use_pcre_u() ) { |
|
| 66 | + if (_wp_can_use_pcre_u()) { |
|
| 67 | 67 | // Use the regex unicode support to separate the UTF-8 characters into an array |
| 68 | - preg_match_all( '/./us', $str, $match ); |
|
| 69 | - $chars = is_null( $length ) ? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); |
|
| 70 | - return implode( '', $chars ); |
|
| 68 | + preg_match_all('/./us', $str, $match); |
|
| 69 | + $chars = is_null($length) ? array_slice($match[0], $start) : array_slice($match[0], $start, $length); |
|
| 70 | + return implode('', $chars); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $regex = '/( |
@@ -82,23 +82,23 @@ discard block |
||
| 82 | 82 | | \xF4[\x80-\x8F][\x80-\xBF]{2} |
| 83 | 83 | )/x'; |
| 84 | 84 | |
| 85 | - $chars = array( '' ); // Start with 1 element instead of 0 since the first thing we do is pop |
|
| 85 | + $chars = array(''); // Start with 1 element instead of 0 since the first thing we do is pop |
|
| 86 | 86 | do { |
| 87 | 87 | // We had some string left over from the last round, but we counted it in that last round. |
| 88 | - array_pop( $chars ); |
|
| 88 | + array_pop($chars); |
|
| 89 | 89 | |
| 90 | 90 | // Split by UTF-8 character, limit to 1000 characters (last array element will contain the rest of the string) |
| 91 | - $pieces = preg_split( $regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); |
|
| 91 | + $pieces = preg_split($regex, $str, 1000, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 92 | 92 | |
| 93 | - $chars = array_merge( $chars, $pieces ); |
|
| 94 | - } while ( count( $pieces ) > 1 && $str = array_pop( $pieces ) ); // If there's anything left over, repeat the loop. |
|
| 93 | + $chars = array_merge($chars, $pieces); |
|
| 94 | + } while (count($pieces) > 1 && $str = array_pop($pieces)); // If there's anything left over, repeat the loop. |
|
| 95 | 95 | |
| 96 | - return join( '', array_slice( $chars, $start, $length ) ); |
|
| 96 | + return join('', array_slice($chars, $start, $length)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | -if ( ! function_exists( 'mb_strlen' ) ) : |
|
| 100 | - function mb_strlen( $str, $encoding = null ) { |
|
| 101 | - return _mb_strlen( $str, $encoding ); |
|
| 99 | +if ( ! function_exists('mb_strlen')) : |
|
| 100 | + function mb_strlen($str, $encoding = null) { |
|
| 101 | + return _mb_strlen($str, $encoding); |
|
| 102 | 102 | } |
| 103 | 103 | endif; |
| 104 | 104 | |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * For $encoding === UTF-8, the $str input is expected to be a valid UTF-8 byte sequence. |
| 108 | 108 | * The behavior of this function for invalid inputs is undefined. |
| 109 | 109 | */ |
| 110 | -function _mb_strlen( $str, $encoding = null ) { |
|
| 111 | - if ( null === $encoding ) { |
|
| 112 | - $encoding = get_option( 'blog_charset' ); |
|
| 110 | +function _mb_strlen($str, $encoding = null) { |
|
| 111 | + if (null === $encoding) { |
|
| 112 | + $encoding = get_option('blog_charset'); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // The solution below works only for UTF-8, |
| 116 | 116 | // so in case of a different charset just use built-in strlen() |
| 117 | - if ( ! in_array( $encoding, array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { |
|
| 118 | - return strlen( $str ); |
|
| 117 | + if ( ! in_array($encoding, array('utf8', 'utf-8', 'UTF8', 'UTF-8'))) { |
|
| 118 | + return strlen($str); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( _wp_can_use_pcre_u() ) { |
|
| 121 | + if (_wp_can_use_pcre_u()) { |
|
| 122 | 122 | // Use the regex unicode support to separate the UTF-8 characters into an array |
| 123 | - preg_match_all( '/./us', $str, $match ); |
|
| 124 | - return count( $match[0] ); |
|
| 123 | + preg_match_all('/./us', $str, $match); |
|
| 124 | + return count($match[0]); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $regex = '/(?: |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | $count--; |
| 143 | 143 | |
| 144 | 144 | // Split by UTF-8 character, limit to 1000 characters (last array element will contain the rest of the string) |
| 145 | - $pieces = preg_split( $regex, $str, 1000 ); |
|
| 145 | + $pieces = preg_split($regex, $str, 1000); |
|
| 146 | 146 | |
| 147 | 147 | // Increment |
| 148 | - $count += count( $pieces ); |
|
| 149 | - } while ( $str = array_pop( $pieces ) ); // If there's anything left over, repeat the loop. |
|
| 148 | + $count += count($pieces); |
|
| 149 | + } while ($str = array_pop($pieces)); // If there's anything left over, repeat the loop. |
|
| 150 | 150 | |
| 151 | 151 | // Fencepost: preg_split() always returns one extra item in the array |
| 152 | 152 | return --$count; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -if ( !function_exists('hash_hmac') ): |
|
| 155 | +if ( ! function_exists('hash_hmac')): |
|
| 156 | 156 | function hash_hmac($algo, $data, $key, $raw_output = false) { |
| 157 | 157 | return _hash_hmac($algo, $data, $key, $raw_output); |
| 158 | 158 | } |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | function _hash_hmac($algo, $data, $key, $raw_output = false) { |
| 162 | 162 | $packs = array('md5' => 'H32', 'sha1' => 'H40'); |
| 163 | 163 | |
| 164 | - if ( !isset($packs[$algo]) ) |
|
| 164 | + if ( ! isset($packs[$algo])) |
|
| 165 | 165 | return false; |
| 166 | 166 | |
| 167 | 167 | $pack = $packs[$algo]; |
@@ -174,44 +174,44 @@ discard block |
||
| 174 | 174 | $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64)); |
| 175 | 175 | $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64)); |
| 176 | 176 | |
| 177 | - $hmac = $algo($opad . pack($pack, $algo($ipad . $data))); |
|
| 177 | + $hmac = $algo($opad.pack($pack, $algo($ipad.$data))); |
|
| 178 | 178 | |
| 179 | - if ( $raw_output ) |
|
| 180 | - return pack( $pack, $hmac ); |
|
| 179 | + if ($raw_output) |
|
| 180 | + return pack($pack, $hmac); |
|
| 181 | 181 | return $hmac; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | -if ( !function_exists('json_encode') ) { |
|
| 185 | - function json_encode( $string ) { |
|
| 184 | +if ( ! function_exists('json_encode')) { |
|
| 185 | + function json_encode($string) { |
|
| 186 | 186 | global $wp_json; |
| 187 | 187 | |
| 188 | - if ( ! ( $wp_json instanceof Services_JSON ) ) { |
|
| 189 | - require_once( ABSPATH . WPINC . '/class-json.php' ); |
|
| 188 | + if ( ! ($wp_json instanceof Services_JSON)) { |
|
| 189 | + require_once(ABSPATH.WPINC.'/class-json.php'); |
|
| 190 | 190 | $wp_json = new Services_JSON(); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - return $wp_json->encodeUnsafe( $string ); |
|
| 193 | + return $wp_json->encodeUnsafe($string); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -if ( !function_exists('json_decode') ) { |
|
| 197 | +if ( ! function_exists('json_decode')) { |
|
| 198 | 198 | /** |
| 199 | 199 | * @global Services_JSON $wp_json |
| 200 | 200 | * @param string $string |
| 201 | 201 | * @param bool $assoc_array |
| 202 | 202 | * @return object|array |
| 203 | 203 | */ |
| 204 | - function json_decode( $string, $assoc_array = false ) { |
|
| 204 | + function json_decode($string, $assoc_array = false) { |
|
| 205 | 205 | global $wp_json; |
| 206 | 206 | |
| 207 | - if ( ! ($wp_json instanceof Services_JSON ) ) { |
|
| 208 | - require_once( ABSPATH . WPINC . '/class-json.php' ); |
|
| 207 | + if ( ! ($wp_json instanceof Services_JSON)) { |
|
| 208 | + require_once(ABSPATH.WPINC.'/class-json.php'); |
|
| 209 | 209 | $wp_json = new Services_JSON(); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $res = $wp_json->decode( $string ); |
|
| 213 | - if ( $assoc_array ) |
|
| 214 | - $res = _json_decode_object_helper( $res ); |
|
| 212 | + $res = $wp_json->decode($string); |
|
| 213 | + if ($assoc_array) |
|
| 214 | + $res = _json_decode_object_helper($res); |
|
| 215 | 215 | return $res; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | * @return array |
| 221 | 221 | */ |
| 222 | 222 | function _json_decode_object_helper($data) { |
| 223 | - if ( is_object($data) ) |
|
| 223 | + if (is_object($data)) |
|
| 224 | 224 | $data = get_object_vars($data); |
| 225 | 225 | return is_array($data) ? array_map(__FUNCTION__, $data) : $data; |
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | -if ( ! function_exists( 'hash_equals' ) ) : |
|
| 229 | +if ( ! function_exists('hash_equals')) : |
|
| 230 | 230 | /** |
| 231 | 231 | * Compare two strings in constant time. |
| 232 | 232 | * |
@@ -239,16 +239,16 @@ discard block |
||
| 239 | 239 | * @param string $b Actual string. |
| 240 | 240 | * @return bool Whether strings are equal. |
| 241 | 241 | */ |
| 242 | -function hash_equals( $a, $b ) { |
|
| 243 | - $a_length = strlen( $a ); |
|
| 244 | - if ( $a_length !== strlen( $b ) ) { |
|
| 242 | +function hash_equals($a, $b) { |
|
| 243 | + $a_length = strlen($a); |
|
| 244 | + if ($a_length !== strlen($b)) { |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | $result = 0; |
| 248 | 248 | |
| 249 | 249 | // Do not attempt to "optimize" this. |
| 250 | - for ( $i = 0; $i < $a_length; $i++ ) { |
|
| 251 | - $result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] ); |
|
| 250 | + for ($i = 0; $i < $a_length; $i++) { |
|
| 251 | + $result |= ord($a[$i]) ^ ord($b[$i]); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $result === 0; |
@@ -257,6 +257,6 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | // JSON_PRETTY_PRINT was introduced in PHP 5.4 |
| 259 | 259 | // Defined here to prevent a notice when using it with wp_json_encode() |
| 260 | -if ( ! defined( 'JSON_PRETTY_PRINT' ) ) { |
|
| 261 | - define( 'JSON_PRETTY_PRINT', 128 ); |
|
| 260 | +if ( ! defined('JSON_PRETTY_PRINT')) { |
|
| 261 | + define('JSON_PRETTY_PRINT', 128); |
|
| 262 | 262 | } |
@@ -161,13 +161,15 @@ discard block |
||
| 161 | 161 | function _hash_hmac($algo, $data, $key, $raw_output = false) { |
| 162 | 162 | $packs = array('md5' => 'H32', 'sha1' => 'H40'); |
| 163 | 163 | |
| 164 | - if ( !isset($packs[$algo]) ) |
|
| 165 | - return false; |
|
| 164 | + if ( !isset($packs[$algo]) ) { |
|
| 165 | + return false; |
|
| 166 | + } |
|
| 166 | 167 | |
| 167 | 168 | $pack = $packs[$algo]; |
| 168 | 169 | |
| 169 | - if (strlen($key) > 64) |
|
| 170 | - $key = pack($pack, $algo($key)); |
|
| 170 | + if (strlen($key) > 64) { |
|
| 171 | + $key = pack($pack, $algo($key)); |
|
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | $key = str_pad($key, 64, chr(0)); |
| 173 | 175 | |
@@ -176,8 +178,9 @@ discard block |
||
| 176 | 178 | |
| 177 | 179 | $hmac = $algo($opad . pack($pack, $algo($ipad . $data))); |
| 178 | 180 | |
| 179 | - if ( $raw_output ) |
|
| 180 | - return pack( $pack, $hmac ); |
|
| 181 | + if ( $raw_output ) { |
|
| 182 | + return pack( $pack, $hmac ); |
|
| 183 | + } |
|
| 181 | 184 | return $hmac; |
| 182 | 185 | } |
| 183 | 186 | |
@@ -210,8 +213,9 @@ discard block |
||
| 210 | 213 | } |
| 211 | 214 | |
| 212 | 215 | $res = $wp_json->decode( $string ); |
| 213 | - if ( $assoc_array ) |
|
| 214 | - $res = _json_decode_object_helper( $res ); |
|
| 216 | + if ( $assoc_array ) { |
|
| 217 | + $res = _json_decode_object_helper( $res ); |
|
| 218 | + } |
|
| 215 | 219 | return $res; |
| 216 | 220 | } |
| 217 | 221 | |
@@ -220,8 +224,9 @@ discard block |
||
| 220 | 224 | * @return array |
| 221 | 225 | */ |
| 222 | 226 | function _json_decode_object_helper($data) { |
| 223 | - if ( is_object($data) ) |
|
| 224 | - $data = get_object_vars($data); |
|
| 227 | + if ( is_object($data) ) { |
|
| 228 | + $data = get_object_vars($data); |
|
| 229 | + } |
|
| 225 | 230 | return is_array($data) ? array_map(__FUNCTION__, $data) : $data; |
| 226 | 231 | } |
| 227 | 232 | } |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | * |
| 800 | 800 | * @param string $compare The compare operator to use |
| 801 | 801 | * @param string|array $value The value |
| 802 | - * @return string|false|int The value to be used in SQL or false on error. |
|
| 802 | + * @return string The value to be used in SQL or false on error. |
|
| 803 | 803 | */ |
| 804 | 804 | public function build_value( $compare, $value ) { |
| 805 | 805 | if ( ! isset( $value ) ) |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | * of $datetime that are arrays, or string values that are a |
| 863 | 863 | * subset of MySQL date format ('Y', 'Y-m', 'Y-m-d', 'Y-m-d H:i'). |
| 864 | 864 | * Default: false. |
| 865 | - * @return string|false A MySQL format date/time or false on failure |
|
| 865 | + * @return string A MySQL format date/time or false on failure |
|
| 866 | 866 | */ |
| 867 | 867 | public function build_mysql_datetime( $datetime, $default_to_max = false ) { |
| 868 | 868 | $now = current_time( 'timestamp' ); |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Class for generating SQL clauses that filter a primary query according to date. |
|
| 4 | - * |
|
| 5 | - * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query}, |
|
| 6 | - * to filter their results by date columns, by generating `WHERE` subclauses to be attached |
|
| 7 | - * to the primary SQL query string. |
|
| 8 | - * |
|
| 9 | - * Attempting to filter by an invalid date value (eg month=13) will generate SQL that will |
|
| 10 | - * return no results. In these cases, a _doing_it_wrong() error notice is also thrown. |
|
| 11 | - * See {@link WP_Date_Query::validate_date_values()}. |
|
| 12 | - * |
|
| 13 | - * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page. |
|
| 14 | - * |
|
| 15 | - * @since 3.7.0 |
|
| 16 | - */ |
|
| 3 | + * Class for generating SQL clauses that filter a primary query according to date. |
|
| 4 | + * |
|
| 5 | + * `WP_Date_Query` is a helper that allows primary query classes, such as {@see WP_Query}, |
|
| 6 | + * to filter their results by date columns, by generating `WHERE` subclauses to be attached |
|
| 7 | + * to the primary SQL query string. |
|
| 8 | + * |
|
| 9 | + * Attempting to filter by an invalid date value (eg month=13) will generate SQL that will |
|
| 10 | + * return no results. In these cases, a _doing_it_wrong() error notice is also thrown. |
|
| 11 | + * See {@link WP_Date_Query::validate_date_values()}. |
|
| 12 | + * |
|
| 13 | + * @link https://codex.wordpress.org/Function_Reference/WP_Query Codex page. |
|
| 14 | + * |
|
| 15 | + * @since 3.7.0 |
|
| 16 | + */ |
|
| 17 | 17 | class WP_Date_Query { |
| 18 | 18 | /** |
| 19 | 19 | * Array of date queries. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @access public |
| 61 | 61 | * @var array |
| 62 | 62 | */ |
| 63 | - public $time_keys = array( 'after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second' ); |
|
| 63 | + public $time_keys = array('after', 'before', 'year', 'month', 'monthnum', 'week', 'w', 'dayofyear', 'day', 'dayofweek', 'dayofweek_iso', 'hour', 'minute', 'second'); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Constructor. |
@@ -150,38 +150,38 @@ discard block |
||
| 150 | 150 | * Accepts 'post_date', 'post_date_gmt', 'post_modified', 'post_modified_gmt', |
| 151 | 151 | * 'comment_date', 'comment_date_gmt'. |
| 152 | 152 | */ |
| 153 | - public function __construct( $date_query, $default_column = 'post_date' ) { |
|
| 153 | + public function __construct($date_query, $default_column = 'post_date') { |
|
| 154 | 154 | |
| 155 | - if ( isset( $date_query['relation'] ) && 'OR' === strtoupper( $date_query['relation'] ) ) { |
|
| 155 | + if (isset($date_query['relation']) && 'OR' === strtoupper($date_query['relation'])) { |
|
| 156 | 156 | $this->relation = 'OR'; |
| 157 | 157 | } else { |
| 158 | 158 | $this->relation = 'AND'; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( ! is_array( $date_query ) ) { |
|
| 161 | + if ( ! is_array($date_query)) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Support for passing time-based keys in the top level of the $date_query array. |
| 166 | - if ( ! isset( $date_query[0] ) && ! empty( $date_query ) ) { |
|
| 167 | - $date_query = array( $date_query ); |
|
| 166 | + if ( ! isset($date_query[0]) && ! empty($date_query)) { |
|
| 167 | + $date_query = array($date_query); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( empty( $date_query ) ) { |
|
| 170 | + if (empty($date_query)) { |
|
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - if ( ! empty( $date_query['column'] ) ) { |
|
| 175 | - $date_query['column'] = esc_sql( $date_query['column'] ); |
|
| 174 | + if ( ! empty($date_query['column'])) { |
|
| 175 | + $date_query['column'] = esc_sql($date_query['column']); |
|
| 176 | 176 | } else { |
| 177 | - $date_query['column'] = esc_sql( $default_column ); |
|
| 177 | + $date_query['column'] = esc_sql($default_column); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - $this->column = $this->validate_column( $this->column ); |
|
| 180 | + $this->column = $this->validate_column($this->column); |
|
| 181 | 181 | |
| 182 | - $this->compare = $this->get_compare( $date_query ); |
|
| 182 | + $this->compare = $this->get_compare($date_query); |
|
| 183 | 183 | |
| 184 | - $this->queries = $this->sanitize_query( $date_query ); |
|
| 184 | + $this->queries = $this->sanitize_query($date_query); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return array Sanitized queries. |
| 201 | 201 | */ |
| 202 | - public function sanitize_query( $queries, $parent_query = null ) { |
|
| 202 | + public function sanitize_query($queries, $parent_query = null) { |
|
| 203 | 203 | $cleaned_query = array(); |
| 204 | 204 | |
| 205 | 205 | $defaults = array( |
@@ -209,37 +209,37 @@ discard block |
||
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | 211 | // Numeric keys should always have array values. |
| 212 | - foreach ( $queries as $qkey => $qvalue ) { |
|
| 213 | - if ( is_numeric( $qkey ) && ! is_array( $qvalue ) ) { |
|
| 214 | - unset( $queries[ $qkey ] ); |
|
| 212 | + foreach ($queries as $qkey => $qvalue) { |
|
| 213 | + if (is_numeric($qkey) && ! is_array($qvalue)) { |
|
| 214 | + unset($queries[$qkey]); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Each query should have a value for each default key. Inherit from the parent when possible. |
| 219 | - foreach ( $defaults as $dkey => $dvalue ) { |
|
| 220 | - if ( isset( $queries[ $dkey ] ) ) { |
|
| 219 | + foreach ($defaults as $dkey => $dvalue) { |
|
| 220 | + if (isset($queries[$dkey])) { |
|
| 221 | 221 | continue; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - if ( isset( $parent_query[ $dkey ] ) ) { |
|
| 225 | - $queries[ $dkey ] = $parent_query[ $dkey ]; |
|
| 224 | + if (isset($parent_query[$dkey])) { |
|
| 225 | + $queries[$dkey] = $parent_query[$dkey]; |
|
| 226 | 226 | } else { |
| 227 | - $queries[ $dkey ] = $dvalue; |
|
| 227 | + $queries[$dkey] = $dvalue; |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Validate the dates passed in the query. |
| 232 | - if ( $this->is_first_order_clause( $queries ) ) { |
|
| 233 | - $this->validate_date_values( $queries ); |
|
| 232 | + if ($this->is_first_order_clause($queries)) { |
|
| 233 | + $this->validate_date_values($queries); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - foreach ( $queries as $key => $q ) { |
|
| 237 | - if ( ! is_array( $q ) || in_array( $key, $this->time_keys, true ) ) { |
|
| 236 | + foreach ($queries as $key => $q) { |
|
| 237 | + if ( ! is_array($q) || in_array($key, $this->time_keys, true)) { |
|
| 238 | 238 | // This is a first-order query. Trust the values and sanitize when building SQL. |
| 239 | - $cleaned_query[ $key ] = $q; |
|
| 239 | + $cleaned_query[$key] = $q; |
|
| 240 | 240 | } else { |
| 241 | 241 | // Any array without a time key is another query, so we recurse. |
| 242 | - $cleaned_query[] = $this->sanitize_query( $q, $queries ); |
|
| 242 | + $cleaned_query[] = $this->sanitize_query($q, $queries); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | * @param array $query Query clause. |
| 256 | 256 | * @return bool True if this is a first-order clause. |
| 257 | 257 | */ |
| 258 | - protected function is_first_order_clause( $query ) { |
|
| 259 | - $time_keys = array_intersect( $this->time_keys, array_keys( $query ) ); |
|
| 260 | - return ! empty( $time_keys ); |
|
| 258 | + protected function is_first_order_clause($query) { |
|
| 259 | + $time_keys = array_intersect($this->time_keys, array_keys($query)); |
|
| 260 | + return ! empty($time_keys); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | * @param array $query A date query or a date subquery. |
| 270 | 270 | * @return string The comparison operator. |
| 271 | 271 | */ |
| 272 | - public function get_compare( $query ) { |
|
| 273 | - if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) |
|
| 274 | - return strtoupper( $query['compare'] ); |
|
| 272 | + public function get_compare($query) { |
|
| 273 | + if ( ! empty($query['compare']) && in_array($query['compare'], array('=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) |
|
| 274 | + return strtoupper($query['compare']); |
|
| 275 | 275 | |
| 276 | 276 | return $this->compare; |
| 277 | 277 | } |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | * @param array $date_query The date_query array. |
| 290 | 290 | * @return bool True if all values in the query are valid, false if one or more fail. |
| 291 | 291 | */ |
| 292 | - public function validate_date_values( $date_query = array() ) { |
|
| 293 | - if ( empty( $date_query ) ) { |
|
| 292 | + public function validate_date_values($date_query = array()) { |
|
| 293 | + if (empty($date_query)) { |
|
| 294 | 294 | return false; |
| 295 | 295 | } |
| 296 | 296 | |
@@ -301,30 +301,30 @@ discard block |
||
| 301 | 301 | * validation routine continue to be sure that all invalid |
| 302 | 302 | * values generate errors too. |
| 303 | 303 | */ |
| 304 | - if ( array_key_exists( 'before', $date_query ) && is_array( $date_query['before'] ) ){ |
|
| 305 | - $valid = $this->validate_date_values( $date_query['before'] ); |
|
| 304 | + if (array_key_exists('before', $date_query) && is_array($date_query['before'])) { |
|
| 305 | + $valid = $this->validate_date_values($date_query['before']); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( array_key_exists( 'after', $date_query ) && is_array( $date_query['after'] ) ){ |
|
| 309 | - $valid = $this->validate_date_values( $date_query['after'] ); |
|
| 308 | + if (array_key_exists('after', $date_query) && is_array($date_query['after'])) { |
|
| 309 | + $valid = $this->validate_date_values($date_query['after']); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Array containing all min-max checks. |
| 313 | 313 | $min_max_checks = array(); |
| 314 | 314 | |
| 315 | 315 | // Days per year. |
| 316 | - if ( array_key_exists( 'year', $date_query ) ) { |
|
| 316 | + if (array_key_exists('year', $date_query)) { |
|
| 317 | 317 | /* |
| 318 | 318 | * If a year exists in the date query, we can use it to get the days. |
| 319 | 319 | * If multiple years are provided (as in a BETWEEN), use the first one. |
| 320 | 320 | */ |
| 321 | - if ( is_array( $date_query['year'] ) ) { |
|
| 322 | - $_year = reset( $date_query['year'] ); |
|
| 321 | + if (is_array($date_query['year'])) { |
|
| 322 | + $_year = reset($date_query['year']); |
|
| 323 | 323 | } else { |
| 324 | 324 | $_year = $date_query['year']; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - $max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1; |
|
| 327 | + $max_days_of_year = date('z', mktime(0, 0, 0, 12, 31, $_year)) + 1; |
|
| 328 | 328 | } else { |
| 329 | 329 | // otherwise we use the max of 366 (leap-year) |
| 330 | 330 | $max_days_of_year = 366; |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | ); |
| 355 | 355 | |
| 356 | 356 | // Weeks per year. |
| 357 | - if ( isset( $_year ) ) { |
|
| 357 | + if (isset($_year)) { |
|
| 358 | 358 | // If we have a specific year, use it to calculate number of weeks. |
| 359 | 359 | $date = new DateTime(); |
| 360 | - $date->setISODate( $_year, 53 ); |
|
| 361 | - $week_count = $date->format( "W" ) === "53" ? 53 : 52; |
|
| 360 | + $date->setISODate($_year, 53); |
|
| 361 | + $week_count = $date->format("W") === "53" ? 53 : 52; |
|
| 362 | 362 | |
| 363 | 363 | } else { |
| 364 | 364 | // Otherwise set the week-count to a maximum of 53. |
@@ -395,26 +395,26 @@ discard block |
||
| 395 | 395 | ); |
| 396 | 396 | |
| 397 | 397 | // Concatenate and throw a notice for each invalid value. |
| 398 | - foreach ( $min_max_checks as $key => $check ) { |
|
| 399 | - if ( ! array_key_exists( $key, $date_query ) ) { |
|
| 398 | + foreach ($min_max_checks as $key => $check) { |
|
| 399 | + if ( ! array_key_exists($key, $date_query)) { |
|
| 400 | 400 | continue; |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | // Throw a notice for each failing value. |
| 404 | - foreach ( (array) $date_query[ $key ] as $_value ) { |
|
| 404 | + foreach ((array) $date_query[$key] as $_value) { |
|
| 405 | 405 | $is_between = $_value >= $check['min'] && $_value <= $check['max']; |
| 406 | 406 | |
| 407 | - if ( ! is_numeric( $_value ) || ! $is_between ) { |
|
| 407 | + if ( ! is_numeric($_value) || ! $is_between) { |
|
| 408 | 408 | $error = sprintf( |
| 409 | 409 | /* translators: Date query invalid date message: 1: invalid value, 2: type of value, 3: minimum valid value, 4: maximum valid value */ |
| 410 | - __( 'Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.' ), |
|
| 411 | - '<code>' . esc_html( $_value ) . '</code>', |
|
| 412 | - '<code>' . esc_html( $key ) . '</code>', |
|
| 413 | - '<code>' . esc_html( $check['min'] ) . '</code>', |
|
| 414 | - '<code>' . esc_html( $check['max'] ) . '</code>' |
|
| 410 | + __('Invalid value %1$s for %2$s. Expected value should be between %3$s and %4$s.'), |
|
| 411 | + '<code>'.esc_html($_value).'</code>', |
|
| 412 | + '<code>'.esc_html($key).'</code>', |
|
| 413 | + '<code>'.esc_html($check['min']).'</code>', |
|
| 414 | + '<code>'.esc_html($check['max']).'</code>' |
|
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | - _doing_it_wrong( __CLASS__, $error, '4.1.0' ); |
|
| 417 | + _doing_it_wrong(__CLASS__, $error, '4.1.0'); |
|
| 418 | 418 | |
| 419 | 419 | $valid = false; |
| 420 | 420 | } |
@@ -422,49 +422,49 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // If we already have invalid date messages, don't bother running through checkdate(). |
| 425 | - if ( ! $valid ) { |
|
| 425 | + if ( ! $valid) { |
|
| 426 | 426 | return $valid; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | $day_month_year_error_msg = ''; |
| 430 | 430 | |
| 431 | - $day_exists = array_key_exists( 'day', $date_query ) && is_numeric( $date_query['day'] ); |
|
| 432 | - $month_exists = array_key_exists( 'month', $date_query ) && is_numeric( $date_query['month'] ); |
|
| 433 | - $year_exists = array_key_exists( 'year', $date_query ) && is_numeric( $date_query['year'] ); |
|
| 431 | + $day_exists = array_key_exists('day', $date_query) && is_numeric($date_query['day']); |
|
| 432 | + $month_exists = array_key_exists('month', $date_query) && is_numeric($date_query['month']); |
|
| 433 | + $year_exists = array_key_exists('year', $date_query) && is_numeric($date_query['year']); |
|
| 434 | 434 | |
| 435 | - if ( $day_exists && $month_exists && $year_exists ) { |
|
| 435 | + if ($day_exists && $month_exists && $year_exists) { |
|
| 436 | 436 | // 1. Checking day, month, year combination. |
| 437 | - if ( ! wp_checkdate( $date_query['month'], $date_query['day'], $date_query['year'], sprintf( '%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day'] ) ) ) { |
|
| 437 | + if ( ! wp_checkdate($date_query['month'], $date_query['day'], $date_query['year'], sprintf('%s-%s-%s', $date_query['year'], $date_query['month'], $date_query['day']))) { |
|
| 438 | 438 | /* translators: 1: year, 2: month, 3: day of month */ |
| 439 | 439 | $day_month_year_error_msg = sprintf( |
| 440 | - __( 'The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.' ), |
|
| 441 | - '<code>' . esc_html( $date_query['year'] ) . '</code>', |
|
| 442 | - '<code>' . esc_html( $date_query['month'] ) . '</code>', |
|
| 443 | - '<code>' . esc_html( $date_query['day'] ) . '</code>' |
|
| 440 | + __('The following values do not describe a valid date: year %1$s, month %2$s, day %3$s.'), |
|
| 441 | + '<code>'.esc_html($date_query['year']).'</code>', |
|
| 442 | + '<code>'.esc_html($date_query['month']).'</code>', |
|
| 443 | + '<code>'.esc_html($date_query['day']).'</code>' |
|
| 444 | 444 | ); |
| 445 | 445 | |
| 446 | 446 | $valid = false; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - } elseif ( $day_exists && $month_exists ) { |
|
| 449 | + } elseif ($day_exists && $month_exists) { |
|
| 450 | 450 | /* |
| 451 | 451 | * 2. checking day, month combination |
| 452 | 452 | * We use 2012 because, as a leap year, it's the most permissive. |
| 453 | 453 | */ |
| 454 | - if ( ! wp_checkdate( $date_query['month'], $date_query['day'], 2012, sprintf( '2012-%s-%s', $date_query['month'], $date_query['day'] ) ) ) { |
|
| 454 | + if ( ! wp_checkdate($date_query['month'], $date_query['day'], 2012, sprintf('2012-%s-%s', $date_query['month'], $date_query['day']))) { |
|
| 455 | 455 | /* translators: 1: month, 2: day of month */ |
| 456 | 456 | $day_month_year_error_msg = sprintf( |
| 457 | - __( 'The following values do not describe a valid date: month %1$s, day %2$s.' ), |
|
| 458 | - '<code>' . esc_html( $date_query['month'] ) . '</code>', |
|
| 459 | - '<code>' . esc_html( $date_query['day'] ) . '</code>' |
|
| 457 | + __('The following values do not describe a valid date: month %1$s, day %2$s.'), |
|
| 458 | + '<code>'.esc_html($date_query['month']).'</code>', |
|
| 459 | + '<code>'.esc_html($date_query['day']).'</code>' |
|
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | $valid = false; |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - if ( ! empty( $day_month_year_error_msg ) ) { |
|
| 467 | - _doing_it_wrong( __CLASS__, $day_month_year_error_msg, '4.1.0' ); |
|
| 466 | + if ( ! empty($day_month_year_error_msg)) { |
|
| 467 | + _doing_it_wrong(__CLASS__, $day_month_year_error_msg, '4.1.0'); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | return $valid; |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @param string $column The user-supplied column name. |
| 485 | 485 | * @return string A validated column name value. |
| 486 | 486 | */ |
| 487 | - public function validate_column( $column ) { |
|
| 487 | + public function validate_column($column) { |
|
| 488 | 488 | global $wpdb; |
| 489 | 489 | |
| 490 | 490 | $valid_columns = array( |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | ); |
| 495 | 495 | |
| 496 | 496 | // Attempt to detect a table prefix. |
| 497 | - if ( false === strpos( $column, '.' ) ) { |
|
| 497 | + if (false === strpos($column, '.')) { |
|
| 498 | 498 | /** |
| 499 | 499 | * Filter the list of valid date query columns. |
| 500 | 500 | * |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * 'post_modified_gmt', 'comment_date', 'comment_date_gmt', |
| 507 | 507 | * 'user_registered' |
| 508 | 508 | */ |
| 509 | - if ( ! in_array( $column, apply_filters( 'date_query_valid_columns', $valid_columns ) ) ) { |
|
| 509 | + if ( ! in_array($column, apply_filters('date_query_valid_columns', $valid_columns))) { |
|
| 510 | 510 | $column = 'post_date'; |
| 511 | 511 | } |
| 512 | 512 | |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | ); |
| 528 | 528 | |
| 529 | 529 | // If it's a known column name, add the appropriate table prefix. |
| 530 | - foreach ( $known_columns as $table_name => $table_columns ) { |
|
| 531 | - if ( in_array( $column, $table_columns ) ) { |
|
| 532 | - $column = $table_name . '.' . $column; |
|
| 530 | + foreach ($known_columns as $table_name => $table_columns) { |
|
| 531 | + if (in_array($column, $table_columns)) { |
|
| 532 | + $column = $table_name.'.'.$column; |
|
| 533 | 533 | break; |
| 534 | 534 | } |
| 535 | 535 | } |
@@ -537,7 +537,7 @@ discard block |
||
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | // Remove unsafe characters. |
| 540 | - return preg_replace( '/[^a-zA-Z0-9_$\.]/', '', $column ); |
|
| 540 | + return preg_replace('/[^a-zA-Z0-9_$\.]/', '', $column); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | * @param string $where WHERE clause of the date query. |
| 562 | 562 | * @param WP_Date_Query $this The WP_Date_Query instance. |
| 563 | 563 | */ |
| 564 | - return apply_filters( 'get_date_sql', $where, $this ); |
|
| 564 | + return apply_filters('get_date_sql', $where, $this); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | * } |
| 582 | 582 | */ |
| 583 | 583 | protected function get_sql_clauses() { |
| 584 | - $sql = $this->get_sql_for_query( $this->queries ); |
|
| 584 | + $sql = $this->get_sql_for_query($this->queries); |
|
| 585 | 585 | |
| 586 | - if ( ! empty( $sql['where'] ) ) { |
|
| 587 | - $sql['where'] = ' AND ' . $sql['where']; |
|
| 586 | + if ( ! empty($sql['where'])) { |
|
| 587 | + $sql['where'] = ' AND '.$sql['where']; |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | return $sql; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 610 | 610 | * } |
| 611 | 611 | */ |
| 612 | - protected function get_sql_for_query( $query, $depth = 0 ) { |
|
| 612 | + protected function get_sql_for_query($query, $depth = 0) { |
|
| 613 | 613 | $sql_chunks = array( |
| 614 | 614 | 'join' => array(), |
| 615 | 615 | 'where' => array(), |
@@ -621,32 +621,32 @@ discard block |
||
| 621 | 621 | ); |
| 622 | 622 | |
| 623 | 623 | $indent = ''; |
| 624 | - for ( $i = 0; $i < $depth; $i++ ) { |
|
| 624 | + for ($i = 0; $i < $depth; $i++) { |
|
| 625 | 625 | $indent .= " "; |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - foreach ( $query as $key => $clause ) { |
|
| 629 | - if ( 'relation' === $key ) { |
|
| 628 | + foreach ($query as $key => $clause) { |
|
| 629 | + if ('relation' === $key) { |
|
| 630 | 630 | $relation = $query['relation']; |
| 631 | - } elseif ( is_array( $clause ) ) { |
|
| 631 | + } elseif (is_array($clause)) { |
|
| 632 | 632 | |
| 633 | 633 | // This is a first-order clause. |
| 634 | - if ( $this->is_first_order_clause( $clause ) ) { |
|
| 635 | - $clause_sql = $this->get_sql_for_clause( $clause, $query ); |
|
| 634 | + if ($this->is_first_order_clause($clause)) { |
|
| 635 | + $clause_sql = $this->get_sql_for_clause($clause, $query); |
|
| 636 | 636 | |
| 637 | - $where_count = count( $clause_sql['where'] ); |
|
| 638 | - if ( ! $where_count ) { |
|
| 637 | + $where_count = count($clause_sql['where']); |
|
| 638 | + if ( ! $where_count) { |
|
| 639 | 639 | $sql_chunks['where'][] = ''; |
| 640 | - } elseif ( 1 === $where_count ) { |
|
| 640 | + } elseif (1 === $where_count) { |
|
| 641 | 641 | $sql_chunks['where'][] = $clause_sql['where'][0]; |
| 642 | 642 | } else { |
| 643 | - $sql_chunks['where'][] = '( ' . implode( ' AND ', $clause_sql['where'] ) . ' )'; |
|
| 643 | + $sql_chunks['where'][] = '( '.implode(' AND ', $clause_sql['where']).' )'; |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $sql_chunks['join'] = array_merge( $sql_chunks['join'], $clause_sql['join'] ); |
|
| 646 | + $sql_chunks['join'] = array_merge($sql_chunks['join'], $clause_sql['join']); |
|
| 647 | 647 | // This is a subquery, so we recurse. |
| 648 | 648 | } else { |
| 649 | - $clause_sql = $this->get_sql_for_query( $clause, $depth + 1 ); |
|
| 649 | + $clause_sql = $this->get_sql_for_query($clause, $depth + 1); |
|
| 650 | 650 | |
| 651 | 651 | $sql_chunks['where'][] = $clause_sql['where']; |
| 652 | 652 | $sql_chunks['join'][] = $clause_sql['join']; |
@@ -655,21 +655,21 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Filter to remove empties. |
| 658 | - $sql_chunks['join'] = array_filter( $sql_chunks['join'] ); |
|
| 659 | - $sql_chunks['where'] = array_filter( $sql_chunks['where'] ); |
|
| 658 | + $sql_chunks['join'] = array_filter($sql_chunks['join']); |
|
| 659 | + $sql_chunks['where'] = array_filter($sql_chunks['where']); |
|
| 660 | 660 | |
| 661 | - if ( empty( $relation ) ) { |
|
| 661 | + if (empty($relation)) { |
|
| 662 | 662 | $relation = 'AND'; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | // Filter duplicate JOIN clauses and combine into a single string. |
| 666 | - if ( ! empty( $sql_chunks['join'] ) ) { |
|
| 667 | - $sql['join'] = implode( ' ', array_unique( $sql_chunks['join'] ) ); |
|
| 666 | + if ( ! empty($sql_chunks['join'])) { |
|
| 667 | + $sql['join'] = implode(' ', array_unique($sql_chunks['join'])); |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | // Generate a single WHERE clause with proper brackets and indentation. |
| 671 | - if ( ! empty( $sql_chunks['where'] ) ) { |
|
| 672 | - $sql['where'] = '( ' . "\n " . $indent . implode( ' ' . "\n " . $indent . $relation . ' ' . "\n " . $indent, $sql_chunks['where'] ) . "\n" . $indent . ')'; |
|
| 671 | + if ( ! empty($sql_chunks['where'])) { |
|
| 672 | + $sql['where'] = '( '."\n ".$indent.implode(' '."\n ".$indent.$relation.' '."\n ".$indent, $sql_chunks['where'])."\n".$indent.')'; |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | return $sql; |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 693 | 693 | * } |
| 694 | 694 | */ |
| 695 | - protected function get_sql_for_subquery( $query ) { |
|
| 696 | - return $this->get_sql_for_clause( $query, '' ); |
|
| 695 | + protected function get_sql_for_subquery($query) { |
|
| 696 | + return $this->get_sql_for_clause($query, ''); |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | /** |
@@ -711,72 +711,72 @@ discard block |
||
| 711 | 711 | * @type string $where SQL fragment to append to the main WHERE clause. |
| 712 | 712 | * } |
| 713 | 713 | */ |
| 714 | - protected function get_sql_for_clause( $query, $parent_query ) { |
|
| 714 | + protected function get_sql_for_clause($query, $parent_query) { |
|
| 715 | 715 | global $wpdb; |
| 716 | 716 | |
| 717 | 717 | // The sub-parts of a $where part. |
| 718 | 718 | $where_parts = array(); |
| 719 | 719 | |
| 720 | - $column = ( ! empty( $query['column'] ) ) ? esc_sql( $query['column'] ) : $this->column; |
|
| 720 | + $column = ( ! empty($query['column'])) ? esc_sql($query['column']) : $this->column; |
|
| 721 | 721 | |
| 722 | - $column = $this->validate_column( $column ); |
|
| 722 | + $column = $this->validate_column($column); |
|
| 723 | 723 | |
| 724 | - $compare = $this->get_compare( $query ); |
|
| 724 | + $compare = $this->get_compare($query); |
|
| 725 | 725 | |
| 726 | - $inclusive = ! empty( $query['inclusive'] ); |
|
| 726 | + $inclusive = ! empty($query['inclusive']); |
|
| 727 | 727 | |
| 728 | 728 | // Assign greater- and less-than values. |
| 729 | 729 | $lt = '<'; |
| 730 | 730 | $gt = '>'; |
| 731 | 731 | |
| 732 | - if ( $inclusive ) { |
|
| 732 | + if ($inclusive) { |
|
| 733 | 733 | $lt .= '='; |
| 734 | 734 | $gt .= '='; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | // Range queries. |
| 738 | - if ( ! empty( $query['after'] ) ) |
|
| 739 | - $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); |
|
| 738 | + if ( ! empty($query['after'])) |
|
| 739 | + $where_parts[] = $wpdb->prepare("$column $gt %s", $this->build_mysql_datetime($query['after'], ! $inclusive)); |
|
| 740 | 740 | |
| 741 | - if ( ! empty( $query['before'] ) ) |
|
| 742 | - $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); |
|
| 741 | + if ( ! empty($query['before'])) |
|
| 742 | + $where_parts[] = $wpdb->prepare("$column $lt %s", $this->build_mysql_datetime($query['before'], $inclusive)); |
|
| 743 | 743 | |
| 744 | 744 | // Specific value queries. |
| 745 | 745 | |
| 746 | - if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) |
|
| 746 | + if (isset($query['year']) && $value = $this->build_value($compare, $query['year'])) |
|
| 747 | 747 | $where_parts[] = "YEAR( $column ) $compare $value"; |
| 748 | 748 | |
| 749 | - if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { |
|
| 749 | + if (isset($query['month']) && $value = $this->build_value($compare, $query['month'])) { |
|
| 750 | 750 | $where_parts[] = "MONTH( $column ) $compare $value"; |
| 751 | - } elseif ( isset( $query['monthnum'] ) && $value = $this->build_value( $compare, $query['monthnum'] ) ) { |
|
| 751 | + } elseif (isset($query['monthnum']) && $value = $this->build_value($compare, $query['monthnum'])) { |
|
| 752 | 752 | $where_parts[] = "MONTH( $column ) $compare $value"; |
| 753 | 753 | } |
| 754 | - if ( isset( $query['week'] ) && false !== ( $value = $this->build_value( $compare, $query['week'] ) ) ) { |
|
| 755 | - $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
|
| 756 | - } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { |
|
| 757 | - $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
|
| 754 | + if (isset($query['week']) && false !== ($value = $this->build_value($compare, $query['week']))) { |
|
| 755 | + $where_parts[] = _wp_mysql_week($column)." $compare $value"; |
|
| 756 | + } elseif (isset($query['w']) && false !== ($value = $this->build_value($compare, $query['w']))) { |
|
| 757 | + $where_parts[] = _wp_mysql_week($column)." $compare $value"; |
|
| 758 | 758 | } |
| 759 | - if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) |
|
| 759 | + if (isset($query['dayofyear']) && $value = $this->build_value($compare, $query['dayofyear'])) |
|
| 760 | 760 | $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
| 761 | 761 | |
| 762 | - if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) |
|
| 762 | + if (isset($query['day']) && $value = $this->build_value($compare, $query['day'])) |
|
| 763 | 763 | $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
| 764 | 764 | |
| 765 | - if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) |
|
| 765 | + if (isset($query['dayofweek']) && $value = $this->build_value($compare, $query['dayofweek'])) |
|
| 766 | 766 | $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
| 767 | 767 | |
| 768 | - if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) |
|
| 768 | + if (isset($query['dayofweek_iso']) && $value = $this->build_value($compare, $query['dayofweek_iso'])) |
|
| 769 | 769 | $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
| 770 | 770 | |
| 771 | - if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { |
|
| 771 | + if (isset($query['hour']) || isset($query['minute']) || isset($query['second'])) { |
|
| 772 | 772 | // Avoid notices. |
| 773 | - foreach ( array( 'hour', 'minute', 'second' ) as $unit ) { |
|
| 774 | - if ( ! isset( $query[ $unit ] ) ) { |
|
| 775 | - $query[ $unit ] = null; |
|
| 773 | + foreach (array('hour', 'minute', 'second') as $unit) { |
|
| 774 | + if ( ! isset($query[$unit])) { |
|
| 775 | + $query[$unit] = null; |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | - if ( $time_query = $this->build_time_query( $column, $compare, $query['hour'], $query['minute'], $query['second'] ) ) { |
|
| 779 | + if ($time_query = $this->build_time_query($column, $compare, $query['hour'], $query['minute'], $query['second'])) { |
|
| 780 | 780 | $where_parts[] = $time_query; |
| 781 | 781 | } |
| 782 | 782 | } |
@@ -801,45 +801,45 @@ discard block |
||
| 801 | 801 | * @param string|array $value The value |
| 802 | 802 | * @return string|false|int The value to be used in SQL or false on error. |
| 803 | 803 | */ |
| 804 | - public function build_value( $compare, $value ) { |
|
| 805 | - if ( ! isset( $value ) ) |
|
| 804 | + public function build_value($compare, $value) { |
|
| 805 | + if ( ! isset($value)) |
|
| 806 | 806 | return false; |
| 807 | 807 | |
| 808 | - switch ( $compare ) { |
|
| 808 | + switch ($compare) { |
|
| 809 | 809 | case 'IN': |
| 810 | 810 | case 'NOT IN': |
| 811 | 811 | $value = (array) $value; |
| 812 | 812 | |
| 813 | 813 | // Remove non-numeric values. |
| 814 | - $value = array_filter( $value, 'is_numeric' ); |
|
| 814 | + $value = array_filter($value, 'is_numeric'); |
|
| 815 | 815 | |
| 816 | - if ( empty( $value ) ) { |
|
| 816 | + if (empty($value)) { |
|
| 817 | 817 | return false; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - return '(' . implode( ',', array_map( 'intval', $value ) ) . ')'; |
|
| 820 | + return '('.implode(',', array_map('intval', $value)).')'; |
|
| 821 | 821 | |
| 822 | 822 | case 'BETWEEN': |
| 823 | 823 | case 'NOT BETWEEN': |
| 824 | - if ( ! is_array( $value ) || 2 != count( $value ) ) { |
|
| 825 | - $value = array( $value, $value ); |
|
| 824 | + if ( ! is_array($value) || 2 != count($value)) { |
|
| 825 | + $value = array($value, $value); |
|
| 826 | 826 | } else { |
| 827 | - $value = array_values( $value ); |
|
| 827 | + $value = array_values($value); |
|
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | // If either value is non-numeric, bail. |
| 831 | - foreach ( $value as $v ) { |
|
| 832 | - if ( ! is_numeric( $v ) ) { |
|
| 831 | + foreach ($value as $v) { |
|
| 832 | + if ( ! is_numeric($v)) { |
|
| 833 | 833 | return false; |
| 834 | 834 | } |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - $value = array_map( 'intval', $value ); |
|
| 837 | + $value = array_map('intval', $value); |
|
| 838 | 838 | |
| 839 | - return $value[0] . ' AND ' . $value[1]; |
|
| 839 | + return $value[0].' AND '.$value[1]; |
|
| 840 | 840 | |
| 841 | 841 | default; |
| 842 | - if ( ! is_numeric( $value ) ) { |
|
| 842 | + if ( ! is_numeric($value)) { |
|
| 843 | 843 | return false; |
| 844 | 844 | } |
| 845 | 845 | |
@@ -864,75 +864,75 @@ discard block |
||
| 864 | 864 | * Default: false. |
| 865 | 865 | * @return string|false A MySQL format date/time or false on failure |
| 866 | 866 | */ |
| 867 | - public function build_mysql_datetime( $datetime, $default_to_max = false ) { |
|
| 868 | - $now = current_time( 'timestamp' ); |
|
| 867 | + public function build_mysql_datetime($datetime, $default_to_max = false) { |
|
| 868 | + $now = current_time('timestamp'); |
|
| 869 | 869 | |
| 870 | - if ( ! is_array( $datetime ) ) { |
|
| 870 | + if ( ! is_array($datetime)) { |
|
| 871 | 871 | |
| 872 | 872 | /* |
| 873 | 873 | * Try to parse some common date formats, so we can detect |
| 874 | 874 | * the level of precision and support the 'inclusive' parameter. |
| 875 | 875 | */ |
| 876 | - if ( preg_match( '/^(\d{4})$/', $datetime, $matches ) ) { |
|
| 876 | + if (preg_match('/^(\d{4})$/', $datetime, $matches)) { |
|
| 877 | 877 | // Y |
| 878 | 878 | $datetime = array( |
| 879 | - 'year' => intval( $matches[1] ), |
|
| 879 | + 'year' => intval($matches[1]), |
|
| 880 | 880 | ); |
| 881 | 881 | |
| 882 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})$/', $datetime, $matches ) ) { |
|
| 882 | + } elseif (preg_match('/^(\d{4})\-(\d{2})$/', $datetime, $matches)) { |
|
| 883 | 883 | // Y-m |
| 884 | 884 | $datetime = array( |
| 885 | - 'year' => intval( $matches[1] ), |
|
| 886 | - 'month' => intval( $matches[2] ), |
|
| 885 | + 'year' => intval($matches[1]), |
|
| 886 | + 'month' => intval($matches[2]), |
|
| 887 | 887 | ); |
| 888 | 888 | |
| 889 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches ) ) { |
|
| 889 | + } elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2})$/', $datetime, $matches)) { |
|
| 890 | 890 | // Y-m-d |
| 891 | 891 | $datetime = array( |
| 892 | - 'year' => intval( $matches[1] ), |
|
| 893 | - 'month' => intval( $matches[2] ), |
|
| 894 | - 'day' => intval( $matches[3] ), |
|
| 892 | + 'year' => intval($matches[1]), |
|
| 893 | + 'month' => intval($matches[2]), |
|
| 894 | + 'day' => intval($matches[3]), |
|
| 895 | 895 | ); |
| 896 | 896 | |
| 897 | - } elseif ( preg_match( '/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches ) ) { |
|
| 897 | + } elseif (preg_match('/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2})$/', $datetime, $matches)) { |
|
| 898 | 898 | // Y-m-d H:i |
| 899 | 899 | $datetime = array( |
| 900 | - 'year' => intval( $matches[1] ), |
|
| 901 | - 'month' => intval( $matches[2] ), |
|
| 902 | - 'day' => intval( $matches[3] ), |
|
| 903 | - 'hour' => intval( $matches[4] ), |
|
| 904 | - 'minute' => intval( $matches[5] ), |
|
| 900 | + 'year' => intval($matches[1]), |
|
| 901 | + 'month' => intval($matches[2]), |
|
| 902 | + 'day' => intval($matches[3]), |
|
| 903 | + 'hour' => intval($matches[4]), |
|
| 904 | + 'minute' => intval($matches[5]), |
|
| 905 | 905 | ); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | // If no match is found, we don't support default_to_max. |
| 909 | - if ( ! is_array( $datetime ) ) { |
|
| 909 | + if ( ! is_array($datetime)) { |
|
| 910 | 910 | // @todo Timezone issues here possibly |
| 911 | - return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) ); |
|
| 911 | + return gmdate('Y-m-d H:i:s', strtotime($datetime, $now)); |
|
| 912 | 912 | } |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - $datetime = array_map( 'absint', $datetime ); |
|
| 915 | + $datetime = array_map('absint', $datetime); |
|
| 916 | 916 | |
| 917 | - if ( ! isset( $datetime['year'] ) ) |
|
| 918 | - $datetime['year'] = gmdate( 'Y', $now ); |
|
| 917 | + if ( ! isset($datetime['year'])) |
|
| 918 | + $datetime['year'] = gmdate('Y', $now); |
|
| 919 | 919 | |
| 920 | - if ( ! isset( $datetime['month'] ) ) |
|
| 921 | - $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
| 920 | + if ( ! isset($datetime['month'])) |
|
| 921 | + $datetime['month'] = ($default_to_max) ? 12 : 1; |
|
| 922 | 922 | |
| 923 | - if ( ! isset( $datetime['day'] ) ) |
|
| 924 | - $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
| 923 | + if ( ! isset($datetime['day'])) |
|
| 924 | + $datetime['day'] = ($default_to_max) ? (int) date('t', mktime(0, 0, 0, $datetime['month'], 1, $datetime['year'])) : 1; |
|
| 925 | 925 | |
| 926 | - if ( ! isset( $datetime['hour'] ) ) |
|
| 927 | - $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
| 926 | + if ( ! isset($datetime['hour'])) |
|
| 927 | + $datetime['hour'] = ($default_to_max) ? 23 : 0; |
|
| 928 | 928 | |
| 929 | - if ( ! isset( $datetime['minute'] ) ) |
|
| 930 | - $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
| 929 | + if ( ! isset($datetime['minute'])) |
|
| 930 | + $datetime['minute'] = ($default_to_max) ? 59 : 0; |
|
| 931 | 931 | |
| 932 | - if ( ! isset( $datetime['second'] ) ) |
|
| 933 | - $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
| 932 | + if ( ! isset($datetime['second'])) |
|
| 933 | + $datetime['second'] = ($default_to_max) ? 59 : 0; |
|
| 934 | 934 | |
| 935 | - return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); |
|
| 935 | + return sprintf('%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second']); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -952,48 +952,48 @@ discard block |
||
| 952 | 952 | * @param int|null $second Optional. A second value (0-59). |
| 953 | 953 | * @return string|false A query part or false on failure. |
| 954 | 954 | */ |
| 955 | - public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { |
|
| 955 | + public function build_time_query($column, $compare, $hour = null, $minute = null, $second = null) { |
|
| 956 | 956 | global $wpdb; |
| 957 | 957 | |
| 958 | 958 | // Have to have at least one |
| 959 | - if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) |
|
| 959 | + if ( ! isset($hour) && ! isset($minute) && ! isset($second)) |
|
| 960 | 960 | return false; |
| 961 | 961 | |
| 962 | 962 | // Complex combined queries aren't supported for multi-value queries |
| 963 | - if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
|
| 963 | + if (in_array($compare, array('IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'))) { |
|
| 964 | 964 | $return = array(); |
| 965 | 965 | |
| 966 | - if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) |
|
| 966 | + if (isset($hour) && false !== ($value = $this->build_value($compare, $hour))) |
|
| 967 | 967 | $return[] = "HOUR( $column ) $compare $value"; |
| 968 | 968 | |
| 969 | - if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) |
|
| 969 | + if (isset($minute) && false !== ($value = $this->build_value($compare, $minute))) |
|
| 970 | 970 | $return[] = "MINUTE( $column ) $compare $value"; |
| 971 | 971 | |
| 972 | - if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) |
|
| 972 | + if (isset($second) && false !== ($value = $this->build_value($compare, $second))) |
|
| 973 | 973 | $return[] = "SECOND( $column ) $compare $value"; |
| 974 | 974 | |
| 975 | - return implode( ' AND ', $return ); |
|
| 975 | + return implode(' AND ', $return); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Cases where just one unit is set |
| 979 | - if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { |
|
| 979 | + if (isset($hour) && ! isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $hour))) { |
|
| 980 | 980 | return "HOUR( $column ) $compare $value"; |
| 981 | - } elseif ( ! isset( $hour ) && isset( $minute ) && ! isset( $second ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { |
|
| 981 | + } elseif ( ! isset($hour) && isset($minute) && ! isset($second) && false !== ($value = $this->build_value($compare, $minute))) { |
|
| 982 | 982 | return "MINUTE( $column ) $compare $value"; |
| 983 | - } elseif ( ! isset( $hour ) && ! isset( $minute ) && isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { |
|
| 983 | + } elseif ( ! isset($hour) && ! isset($minute) && isset($second) && false !== ($value = $this->build_value($compare, $second))) { |
|
| 984 | 984 | return "SECOND( $column ) $compare $value"; |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // Single units were already handled. Since hour & second isn't allowed, minute must to be set. |
| 988 | - if ( ! isset( $minute ) ) |
|
| 988 | + if ( ! isset($minute)) |
|
| 989 | 989 | return false; |
| 990 | 990 | |
| 991 | 991 | $format = $time = ''; |
| 992 | 992 | |
| 993 | 993 | // Hour |
| 994 | - if ( $hour ) { |
|
| 994 | + if ($hour) { |
|
| 995 | 995 | $format .= '%H.'; |
| 996 | - $time .= sprintf( '%02d', $hour ) . '.'; |
|
| 996 | + $time .= sprintf('%02d', $hour).'.'; |
|
| 997 | 997 | } else { |
| 998 | 998 | $format .= '0.'; |
| 999 | 999 | $time .= '0.'; |
@@ -1001,13 +1001,13 @@ discard block |
||
| 1001 | 1001 | |
| 1002 | 1002 | // Minute |
| 1003 | 1003 | $format .= '%i'; |
| 1004 | - $time .= sprintf( '%02d', $minute ); |
|
| 1004 | + $time .= sprintf('%02d', $minute); |
|
| 1005 | 1005 | |
| 1006 | - if ( isset( $second ) ) { |
|
| 1006 | + if (isset($second)) { |
|
| 1007 | 1007 | $format .= '%s'; |
| 1008 | - $time .= sprintf( '%02d', $second ); |
|
| 1008 | + $time .= sprintf('%02d', $second); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - return $wpdb->prepare( "DATE_FORMAT( $column, %s ) $compare %f", $format, $time ); |
|
| 1011 | + return $wpdb->prepare("DATE_FORMAT( $column, %s ) $compare %f", $format, $time); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | } |
@@ -270,8 +270,9 @@ discard block |
||
| 270 | 270 | * @return string The comparison operator. |
| 271 | 271 | */ |
| 272 | 272 | public function get_compare( $query ) { |
| 273 | - if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) |
|
| 274 | - return strtoupper( $query['compare'] ); |
|
| 273 | + if ( ! empty( $query['compare'] ) && in_array( $query['compare'], array( '=', '!=', '>', '>=', '<', '<=', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
|
| 274 | + return strtoupper( $query['compare'] ); |
|
| 275 | + } |
|
| 275 | 276 | |
| 276 | 277 | return $this->compare; |
| 277 | 278 | } |
@@ -735,16 +736,19 @@ discard block |
||
| 735 | 736 | } |
| 736 | 737 | |
| 737 | 738 | // Range queries. |
| 738 | - if ( ! empty( $query['after'] ) ) |
|
| 739 | - $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); |
|
| 739 | + if ( ! empty( $query['after'] ) ) { |
|
| 740 | + $where_parts[] = $wpdb->prepare( "$column $gt %s", $this->build_mysql_datetime( $query['after'], ! $inclusive ) ); |
|
| 741 | + } |
|
| 740 | 742 | |
| 741 | - if ( ! empty( $query['before'] ) ) |
|
| 742 | - $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); |
|
| 743 | + if ( ! empty( $query['before'] ) ) { |
|
| 744 | + $where_parts[] = $wpdb->prepare( "$column $lt %s", $this->build_mysql_datetime( $query['before'], $inclusive ) ); |
|
| 745 | + } |
|
| 743 | 746 | |
| 744 | 747 | // Specific value queries. |
| 745 | 748 | |
| 746 | - if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) |
|
| 747 | - $where_parts[] = "YEAR( $column ) $compare $value"; |
|
| 749 | + if ( isset( $query['year'] ) && $value = $this->build_value( $compare, $query['year'] ) ) { |
|
| 750 | + $where_parts[] = "YEAR( $column ) $compare $value"; |
|
| 751 | + } |
|
| 748 | 752 | |
| 749 | 753 | if ( isset( $query['month'] ) && $value = $this->build_value( $compare, $query['month'] ) ) { |
| 750 | 754 | $where_parts[] = "MONTH( $column ) $compare $value"; |
@@ -756,17 +760,21 @@ discard block |
||
| 756 | 760 | } elseif ( isset( $query['w'] ) && false !== ( $value = $this->build_value( $compare, $query['w'] ) ) ) { |
| 757 | 761 | $where_parts[] = _wp_mysql_week( $column ) . " $compare $value"; |
| 758 | 762 | } |
| 759 | - if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) |
|
| 760 | - $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
|
| 763 | + if ( isset( $query['dayofyear'] ) && $value = $this->build_value( $compare, $query['dayofyear'] ) ) { |
|
| 764 | + $where_parts[] = "DAYOFYEAR( $column ) $compare $value"; |
|
| 765 | + } |
|
| 761 | 766 | |
| 762 | - if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) |
|
| 763 | - $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
|
| 767 | + if ( isset( $query['day'] ) && $value = $this->build_value( $compare, $query['day'] ) ) { |
|
| 768 | + $where_parts[] = "DAYOFMONTH( $column ) $compare $value"; |
|
| 769 | + } |
|
| 764 | 770 | |
| 765 | - if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) |
|
| 766 | - $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
|
| 771 | + if ( isset( $query['dayofweek'] ) && $value = $this->build_value( $compare, $query['dayofweek'] ) ) { |
|
| 772 | + $where_parts[] = "DAYOFWEEK( $column ) $compare $value"; |
|
| 773 | + } |
|
| 767 | 774 | |
| 768 | - if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) |
|
| 769 | - $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
|
| 775 | + if ( isset( $query['dayofweek_iso'] ) && $value = $this->build_value( $compare, $query['dayofweek_iso'] ) ) { |
|
| 776 | + $where_parts[] = "WEEKDAY( $column ) + 1 $compare $value"; |
|
| 777 | + } |
|
| 770 | 778 | |
| 771 | 779 | if ( isset( $query['hour'] ) || isset( $query['minute'] ) || isset( $query['second'] ) ) { |
| 772 | 780 | // Avoid notices. |
@@ -802,8 +810,9 @@ discard block |
||
| 802 | 810 | * @return string|false|int The value to be used in SQL or false on error. |
| 803 | 811 | */ |
| 804 | 812 | public function build_value( $compare, $value ) { |
| 805 | - if ( ! isset( $value ) ) |
|
| 806 | - return false; |
|
| 813 | + if ( ! isset( $value ) ) { |
|
| 814 | + return false; |
|
| 815 | + } |
|
| 807 | 816 | |
| 808 | 817 | switch ( $compare ) { |
| 809 | 818 | case 'IN': |
@@ -914,23 +923,29 @@ discard block |
||
| 914 | 923 | |
| 915 | 924 | $datetime = array_map( 'absint', $datetime ); |
| 916 | 925 | |
| 917 | - if ( ! isset( $datetime['year'] ) ) |
|
| 918 | - $datetime['year'] = gmdate( 'Y', $now ); |
|
| 926 | + if ( ! isset( $datetime['year'] ) ) { |
|
| 927 | + $datetime['year'] = gmdate( 'Y', $now ); |
|
| 928 | + } |
|
| 919 | 929 | |
| 920 | - if ( ! isset( $datetime['month'] ) ) |
|
| 921 | - $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
| 930 | + if ( ! isset( $datetime['month'] ) ) { |
|
| 931 | + $datetime['month'] = ( $default_to_max ) ? 12 : 1; |
|
| 932 | + } |
|
| 922 | 933 | |
| 923 | - if ( ! isset( $datetime['day'] ) ) |
|
| 924 | - $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
| 934 | + if ( ! isset( $datetime['day'] ) ) { |
|
| 935 | + $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; |
|
| 936 | + } |
|
| 925 | 937 | |
| 926 | - if ( ! isset( $datetime['hour'] ) ) |
|
| 927 | - $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
| 938 | + if ( ! isset( $datetime['hour'] ) ) { |
|
| 939 | + $datetime['hour'] = ( $default_to_max ) ? 23 : 0; |
|
| 940 | + } |
|
| 928 | 941 | |
| 929 | - if ( ! isset( $datetime['minute'] ) ) |
|
| 930 | - $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
| 942 | + if ( ! isset( $datetime['minute'] ) ) { |
|
| 943 | + $datetime['minute'] = ( $default_to_max ) ? 59 : 0; |
|
| 944 | + } |
|
| 931 | 945 | |
| 932 | - if ( ! isset( $datetime['second'] ) ) |
|
| 933 | - $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
| 946 | + if ( ! isset( $datetime['second'] ) ) { |
|
| 947 | + $datetime['second'] = ( $default_to_max ) ? 59 : 0; |
|
| 948 | + } |
|
| 934 | 949 | |
| 935 | 950 | return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); |
| 936 | 951 | } |
@@ -956,21 +971,25 @@ discard block |
||
| 956 | 971 | global $wpdb; |
| 957 | 972 | |
| 958 | 973 | // Have to have at least one |
| 959 | - if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) |
|
| 960 | - return false; |
|
| 974 | + if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) { |
|
| 975 | + return false; |
|
| 976 | + } |
|
| 961 | 977 | |
| 962 | 978 | // Complex combined queries aren't supported for multi-value queries |
| 963 | 979 | if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { |
| 964 | 980 | $return = array(); |
| 965 | 981 | |
| 966 | - if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) |
|
| 967 | - $return[] = "HOUR( $column ) $compare $value"; |
|
| 982 | + if ( isset( $hour ) && false !== ( $value = $this->build_value( $compare, $hour ) ) ) { |
|
| 983 | + $return[] = "HOUR( $column ) $compare $value"; |
|
| 984 | + } |
|
| 968 | 985 | |
| 969 | - if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) |
|
| 970 | - $return[] = "MINUTE( $column ) $compare $value"; |
|
| 986 | + if ( isset( $minute ) && false !== ( $value = $this->build_value( $compare, $minute ) ) ) { |
|
| 987 | + $return[] = "MINUTE( $column ) $compare $value"; |
|
| 988 | + } |
|
| 971 | 989 | |
| 972 | - if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) |
|
| 973 | - $return[] = "SECOND( $column ) $compare $value"; |
|
| 990 | + if ( isset( $second ) && false !== ( $value = $this->build_value( $compare, $second ) ) ) { |
|
| 991 | + $return[] = "SECOND( $column ) $compare $value"; |
|
| 992 | + } |
|
| 974 | 993 | |
| 975 | 994 | return implode( ' AND ', $return ); |
| 976 | 995 | } |
@@ -985,8 +1004,9 @@ discard block |
||
| 985 | 1004 | } |
| 986 | 1005 | |
| 987 | 1006 | // Single units were already handled. Since hour & second isn't allowed, minute must to be set. |
| 988 | - if ( ! isset( $minute ) ) |
|
| 989 | - return false; |
|
| 1007 | + if ( ! isset( $minute ) ) { |
|
| 1008 | + return false; |
|
| 1009 | + } |
|
| 990 | 1010 | |
| 991 | 1011 | $format = $time = ''; |
| 992 | 1012 | |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * @param string $feed_image |
| 611 | 611 | * @param string $exclude |
| 612 | 612 | * @param bool $hierarchical |
| 613 | - * @return false|null |
|
| 613 | + * @return false|string |
|
| 614 | 614 | */ |
| 615 | 615 | function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, |
| 616 | 616 | $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | * @see wp_list_categories() |
| 631 | 631 | * |
| 632 | 632 | * @param string|array $args |
| 633 | - * @return false|null|string |
|
| 633 | + * @return false|string |
|
| 634 | 634 | */ |
| 635 | 635 | function wp_list_cats($args = '') { |
| 636 | 636 | _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' ); |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @param bool $echo |
| 781 | 781 | * @param int $author_id |
| 782 | 782 | * @param string $author_nicename Optional. |
| 783 | - * @return string|null |
|
| 783 | + * @return string |
|
| 784 | 784 | */ |
| 785 | 785 | function get_author_link($echo, $author_id, $author_nicename = '') { |
| 786 | 786 | _deprecated_function( __FUNCTION__, '2.1', 'get_author_posts_url()' ); |
@@ -1600,7 +1600,7 @@ discard block |
||
| 1600 | 1600 | * @deprecated 2.8.0 Use get_the_author_meta() |
| 1601 | 1601 | * @see get_the_author_meta() |
| 1602 | 1602 | * |
| 1603 | - * @return string|int The author's ID. |
|
| 1603 | + * @return string The author's ID. |
|
| 1604 | 1604 | */ |
| 1605 | 1605 | function get_the_author_ID() { |
| 1606 | 1606 | _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' ); |
@@ -2082,7 +2082,6 @@ discard block |
||
| 2082 | 2082 | * @param string|int $name Widget ID. |
| 2083 | 2083 | * @param callback $output_callback Run when widget is called. |
| 2084 | 2084 | * @param string $classname Classname widget option. |
| 2085 | - * @param mixed $params ,... Widget parameters. |
|
| 2086 | 2085 | */ |
| 2087 | 2086 | function register_sidebar_widget($name, $output_callback, $classname = '') { |
| 2088 | 2087 | _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' ); |
@@ -3552,7 +3551,7 @@ discard block |
||
| 3552 | 3551 | * @deprecated 4.4.0 Use get_permalink() |
| 3553 | 3552 | * @see get_permalink() |
| 3554 | 3553 | * |
| 3555 | - * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3554 | + * @param integer $post_id Optional. Post ID or WP_Post object. Default is global $post. |
|
| 3556 | 3555 | * @return string|false |
| 3557 | 3556 | */ |
| 3558 | 3557 | function post_permalink( $post_id = 0 ) { |
@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Deprecated functions from past WordPress versions. You shouldn't use these |
|
| 4 | - * functions and look for the alternatives instead. The functions will be |
|
| 5 | - * removed in a later version. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - * @subpackage Deprecated |
|
| 9 | - */ |
|
| 3 | + * Deprecated functions from past WordPress versions. You shouldn't use these |
|
| 4 | + * functions and look for the alternatives instead. The functions will be |
|
| 5 | + * removed in a later version. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + * @subpackage Deprecated |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | /* |
| 12 | 12 | * Deprecated functions come here to die. |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | * @return array |
| 24 | 24 | */ |
| 25 | 25 | function get_postdata($postid) { |
| 26 | - _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); |
|
| 26 | + _deprecated_function(__FUNCTION__, '1.5.1', 'get_post()'); |
|
| 27 | 27 | |
| 28 | 28 | $post = get_post($postid); |
| 29 | 29 | |
| 30 | - $postdata = array ( |
|
| 30 | + $postdata = array( |
|
| 31 | 31 | 'ID' => $post->ID, |
| 32 | 32 | 'Author_ID' => $post->post_author, |
| 33 | 33 | 'Date' => $post->post_date, |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | function start_wp() { |
| 62 | 62 | global $wp_query; |
| 63 | 63 | |
| 64 | - _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') ); |
|
| 64 | + _deprecated_function(__FUNCTION__, '1.5', __('new WordPress Loop')); |
|
| 65 | 65 | |
| 66 | 66 | // Since the old style loop is being used, advance the query iterator here. |
| 67 | 67 | $wp_query->next_post(); |
| 68 | 68 | |
| 69 | - setup_postdata( get_post() ); |
|
| 69 | + setup_postdata(get_post()); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | * @return null|int |
| 81 | 81 | */ |
| 82 | 82 | function the_category_ID($echo = true) { |
| 83 | - _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); |
|
| 83 | + _deprecated_function(__FUNCTION__, '0.71', 'get_the_category()'); |
|
| 84 | 84 | |
| 85 | 85 | // Grab the first cat in the list. |
| 86 | 86 | $categories = get_the_category(); |
| 87 | 87 | $cat = $categories[0]->term_id; |
| 88 | 88 | |
| 89 | - if ( $echo ) |
|
| 89 | + if ($echo) |
|
| 90 | 90 | echo $cat; |
| 91 | 91 | |
| 92 | 92 | return $cat; |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | * @param string $before |
| 103 | 103 | * @param string $after |
| 104 | 104 | */ |
| 105 | -function the_category_head($before='', $after='') { |
|
| 105 | +function the_category_head($before = '', $after = '') { |
|
| 106 | 106 | global $currentcat, $previouscat; |
| 107 | 107 | |
| 108 | - _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); |
|
| 108 | + _deprecated_function(__FUNCTION__, '0.71', 'get_the_category_by_ID()'); |
|
| 109 | 109 | |
| 110 | 110 | // Grab the first cat in the list. |
| 111 | 111 | $categories = get_the_category(); |
| 112 | 112 | $currentcat = $categories[0]->category_id; |
| 113 | - if ( $currentcat != $previouscat ) { |
|
| 113 | + if ($currentcat != $previouscat) { |
|
| 114 | 114 | echo $before; |
| 115 | 115 | echo get_the_category_by_ID($currentcat); |
| 116 | 116 | echo $after; |
@@ -132,22 +132,22 @@ discard block |
||
| 132 | 132 | * @param int $limitprev |
| 133 | 133 | * @param string $excluded_categories |
| 134 | 134 | */ |
| 135 | -function previous_post($format='%', $previous='previous post: ', $title='yes', $in_same_cat='no', $limitprev=1, $excluded_categories='') { |
|
| 135 | +function previous_post($format = '%', $previous = 'previous post: ', $title = 'yes', $in_same_cat = 'no', $limitprev = 1, $excluded_categories = '') { |
|
| 136 | 136 | |
| 137 | - _deprecated_function( __FUNCTION__, '2.0', 'previous_post_link()' ); |
|
| 137 | + _deprecated_function(__FUNCTION__, '2.0', 'previous_post_link()'); |
|
| 138 | 138 | |
| 139 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
| 139 | + if (empty($in_same_cat) || 'no' == $in_same_cat) |
|
| 140 | 140 | $in_same_cat = false; |
| 141 | 141 | else |
| 142 | 142 | $in_same_cat = true; |
| 143 | 143 | |
| 144 | 144 | $post = get_previous_post($in_same_cat, $excluded_categories); |
| 145 | 145 | |
| 146 | - if ( !$post ) |
|
| 146 | + if ( ! $post) |
|
| 147 | 147 | return; |
| 148 | 148 | |
| 149 | 149 | $string = '<a href="'.get_permalink($post->ID).'">'.$previous; |
| 150 | - if ( 'yes' == $title ) |
|
| 150 | + if ('yes' == $title) |
|
| 151 | 151 | $string .= apply_filters('the_title', $post->post_title, $post->ID); |
| 152 | 152 | $string .= '</a>'; |
| 153 | 153 | $format = str_replace('%', $string, $format); |
@@ -168,21 +168,21 @@ discard block |
||
| 168 | 168 | * @param int $limitnext |
| 169 | 169 | * @param string $excluded_categories |
| 170 | 170 | */ |
| 171 | -function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { |
|
| 172 | - _deprecated_function( __FUNCTION__, '2.0', 'next_post_link()' ); |
|
| 171 | +function next_post($format = '%', $next = 'next post: ', $title = 'yes', $in_same_cat = 'no', $limitnext = 1, $excluded_categories = '') { |
|
| 172 | + _deprecated_function(__FUNCTION__, '2.0', 'next_post_link()'); |
|
| 173 | 173 | |
| 174 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
| 174 | + if (empty($in_same_cat) || 'no' == $in_same_cat) |
|
| 175 | 175 | $in_same_cat = false; |
| 176 | 176 | else |
| 177 | 177 | $in_same_cat = true; |
| 178 | 178 | |
| 179 | 179 | $post = get_next_post($in_same_cat, $excluded_categories); |
| 180 | 180 | |
| 181 | - if ( !$post ) |
|
| 181 | + if ( ! $post) |
|
| 182 | 182 | return; |
| 183 | 183 | |
| 184 | 184 | $string = '<a href="'.get_permalink($post->ID).'">'.$next; |
| 185 | - if ( 'yes' == $title ) |
|
| 185 | + if ('yes' == $title) |
|
| 186 | 186 | $string .= apply_filters('the_title', $post->post_title, $post->ID); |
| 187 | 187 | $string .= '</a>'; |
| 188 | 188 | $format = str_replace('%', $string, $format); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return bool |
| 203 | 203 | */ |
| 204 | 204 | function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') { |
| 205 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 205 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 206 | 206 | |
| 207 | 207 | $author_data = get_userdata($user_id); |
| 208 | 208 | return ($author_data->user_level > 1); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @return bool |
| 222 | 222 | */ |
| 223 | 223 | function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') { |
| 224 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 224 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 225 | 225 | |
| 226 | 226 | $author_data = get_userdata($user_id); |
| 227 | 227 | return ($author_data->user_level >= 1); |
@@ -240,15 +240,15 @@ discard block |
||
| 240 | 240 | * @return bool |
| 241 | 241 | */ |
| 242 | 242 | function user_can_edit_post($user_id, $post_id, $blog_id = 1) { |
| 243 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 243 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 244 | 244 | |
| 245 | 245 | $author_data = get_userdata($user_id); |
| 246 | 246 | $post = get_post($post_id); |
| 247 | 247 | $post_author_data = get_userdata($post->post_author); |
| 248 | 248 | |
| 249 | - if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) |
|
| 249 | + if ((($user_id == $post_author_data->ID) && ! ($post->post_status == 'publish' && $author_data->user_level < 2)) |
|
| 250 | 250 | || ($author_data->user_level > $post_author_data->user_level) |
| 251 | - || ($author_data->user_level >= 10) ) { |
|
| 251 | + || ($author_data->user_level >= 10)) { |
|
| 252 | 252 | return true; |
| 253 | 253 | } else { |
| 254 | 254 | return false; |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @return bool |
| 269 | 269 | */ |
| 270 | 270 | function user_can_delete_post($user_id, $post_id, $blog_id = 1) { |
| 271 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 271 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 272 | 272 | |
| 273 | 273 | // right now if one can edit, one can delete |
| 274 | 274 | return user_can_edit_post($user_id, $post_id, $blog_id); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * @return bool |
| 288 | 288 | */ |
| 289 | 289 | function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') { |
| 290 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 290 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 291 | 291 | |
| 292 | 292 | $author_data = get_userdata($user_id); |
| 293 | 293 | return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id)); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return bool returns true if $user_id can edit $post_id's date |
| 307 | 307 | */ |
| 308 | 308 | function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { |
| 309 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 309 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 310 | 310 | |
| 311 | 311 | $author_data = get_userdata($user_id); |
| 312 | 312 | return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id)); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @return bool returns true if $user_id can edit $post_id's comments |
| 326 | 326 | */ |
| 327 | 327 | function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { |
| 328 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 328 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 329 | 329 | |
| 330 | 330 | // right now if one can edit a post, one can edit comments made on it |
| 331 | 331 | return user_can_edit_post($user_id, $post_id, $blog_id); |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @return bool returns true if $user_id can delete $post_id's comments |
| 345 | 345 | */ |
| 346 | 346 | function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { |
| 347 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 347 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 348 | 348 | |
| 349 | 349 | // right now if one can edit comments, one can delete comments |
| 350 | 350 | return user_can_edit_post_comments($user_id, $post_id, $blog_id); |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | * @return bool |
| 363 | 363 | */ |
| 364 | 364 | function user_can_edit_user($user_id, $other_user) { |
| 365 | - _deprecated_function( __FUNCTION__, '2.0', 'current_user_can()' ); |
|
| 365 | + _deprecated_function(__FUNCTION__, '2.0', 'current_user_can()'); |
|
| 366 | 366 | |
| 367 | 367 | $user = get_userdata($user_id); |
| 368 | 368 | $other = get_userdata($other_user); |
| 369 | - if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) |
|
| 369 | + if ($user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID) |
|
| 370 | 370 | return true; |
| 371 | 371 | else |
| 372 | 372 | return false; |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $between = " ", $show_images = true, $orderby = 'id', |
| 396 | 396 | $show_description = true, $show_rating = false, |
| 397 | 397 | $limit = -1, $show_updated = 0) { |
| 398 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 398 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 399 | 399 | |
| 400 | 400 | $cat_id = -1; |
| 401 | 401 | $cat = get_term_by('name', $cat_name, 'link_category'); |
| 402 | - if ( $cat ) |
|
| 402 | + if ($cat) |
|
| 403 | 403 | $cat_id = $cat->term_id; |
| 404 | 404 | |
| 405 | 405 | get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | 'title_li' => '', |
| 431 | 431 | ); |
| 432 | 432 | |
| 433 | - $r = wp_parse_args( $args, $defaults ); |
|
| 433 | + $r = wp_parse_args($args, $defaults); |
|
| 434 | 434 | |
| 435 | 435 | return wp_list_bookmarks($r); |
| 436 | 436 | } |
@@ -454,12 +454,12 @@ discard block |
||
| 454 | 454 | * @param int $limit Limit to X entries. If not specified, all entries are shown. |
| 455 | 455 | * @return array |
| 456 | 456 | */ |
| 457 | -function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { |
|
| 458 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 457 | +function get_linkobjectsbyname($cat_name = "noname", $orderby = 'name', $limit = -1) { |
|
| 458 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 459 | 459 | |
| 460 | 460 | $cat_id = -1; |
| 461 | 461 | $cat = get_term_by('name', $cat_name, 'link_category'); |
| 462 | - if ( $cat ) |
|
| 462 | + if ($cat) |
|
| 463 | 463 | $cat_id = $cat->term_id; |
| 464 | 464 | |
| 465 | 465 | return get_linkobjects($cat_id, $orderby, $limit); |
@@ -506,9 +506,9 @@ discard block |
||
| 506 | 506 | * @return array |
| 507 | 507 | */ |
| 508 | 508 | function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { |
| 509 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 509 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 510 | 510 | |
| 511 | - $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; |
|
| 511 | + $links = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'limit' => $limit)); |
|
| 512 | 512 | |
| 513 | 513 | $links_array = array(); |
| 514 | 514 | foreach ($links as $link) |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | */ |
| 540 | 540 | function get_linksbyname_withrating($cat_name = "noname", $before = '', $after = '<br />', $between = " ", |
| 541 | 541 | $show_images = true, $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
| 542 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 542 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 543 | 543 | |
| 544 | 544 | get_linksbyname($cat_name, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
| 545 | 545 | } |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | function get_links_withrating($category = -1, $before = '', $after = '<br />', $between = " ", $show_images = true, |
| 568 | 568 | $orderby = 'id', $show_description = true, $limit = -1, $show_updated = 0) { |
| 569 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 569 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 570 | 570 | |
| 571 | 571 | get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, true, $limit, $show_updated); |
| 572 | 572 | } |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return int Only returns 0. |
| 582 | 582 | */ |
| 583 | 583 | function get_autotoggle($id = 0) { |
| 584 | - _deprecated_function( __FUNCTION__, '2.1' ); |
|
| 584 | + _deprecated_function(__FUNCTION__, '2.1'); |
|
| 585 | 585 | return 0; |
| 586 | 586 | } |
| 587 | 587 | |
@@ -613,9 +613,9 @@ discard block |
||
| 613 | 613 | * @return false|null |
| 614 | 614 | */ |
| 615 | 615 | function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, |
| 616 | - $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=false, $child_of=0, $categories=0, |
|
| 617 | - $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=false) { |
|
| 618 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' ); |
|
| 616 | + $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children = false, $child_of = 0, $categories = 0, |
|
| 617 | + $recurse = 0, $feed = '', $feed_image = '', $exclude = '', $hierarchical = false) { |
|
| 618 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_categories()'); |
|
| 619 | 619 | |
| 620 | 620 | $query = compact('optionall', 'all', 'sort_column', 'sort_order', 'file', 'list', 'optiondates', 'optioncount', 'hide_empty', 'use_desc_for_title', 'children', |
| 621 | 621 | 'child_of', 'categories', 'recurse', 'feed', 'feed_image', 'exclude', 'hierarchical'); |
@@ -633,22 +633,22 @@ discard block |
||
| 633 | 633 | * @return false|null|string |
| 634 | 634 | */ |
| 635 | 635 | function wp_list_cats($args = '') { |
| 636 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_list_categories()' ); |
|
| 636 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_categories()'); |
|
| 637 | 637 | |
| 638 | - $r = wp_parse_args( $args ); |
|
| 638 | + $r = wp_parse_args($args); |
|
| 639 | 639 | |
| 640 | 640 | // Map to new names. |
| 641 | - if ( isset($r['optionall']) && isset($r['all'])) |
|
| 641 | + if (isset($r['optionall']) && isset($r['all'])) |
|
| 642 | 642 | $r['show_option_all'] = $r['all']; |
| 643 | - if ( isset($r['sort_column']) ) |
|
| 643 | + if (isset($r['sort_column'])) |
|
| 644 | 644 | $r['orderby'] = $r['sort_column']; |
| 645 | - if ( isset($r['sort_order']) ) |
|
| 645 | + if (isset($r['sort_order'])) |
|
| 646 | 646 | $r['order'] = $r['sort_order']; |
| 647 | - if ( isset($r['optiondates']) ) |
|
| 647 | + if (isset($r['optiondates'])) |
|
| 648 | 648 | $r['show_last_update'] = $r['optiondates']; |
| 649 | - if ( isset($r['optioncount']) ) |
|
| 649 | + if (isset($r['optioncount'])) |
|
| 650 | 650 | $r['show_count'] = $r['optioncount']; |
| 651 | - if ( isset($r['list']) ) |
|
| 651 | + if (isset($r['list'])) |
|
| 652 | 652 | $r['style'] = $r['list'] ? 'list' : 'break'; |
| 653 | 653 | $r['title_li'] = ''; |
| 654 | 654 | |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', |
| 678 | 678 | $show_last_update = 0, $show_count = 0, $hide_empty = 1, $optionnone = false, |
| 679 | 679 | $selected = 0, $exclude = 0) { |
| 680 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_dropdown_categories()' ); |
|
| 680 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_dropdown_categories()'); |
|
| 681 | 681 | |
| 682 | 682 | $show_option_all = ''; |
| 683 | - if ( $optionall ) |
|
| 683 | + if ($optionall) |
|
| 684 | 684 | $show_option_all = $all; |
| 685 | 685 | |
| 686 | 686 | $show_option_none = ''; |
| 687 | - if ( $optionnone ) |
|
| 687 | + if ($optionnone) |
|
| 688 | 688 | $show_option_none = __('None'); |
| 689 | 689 | |
| 690 | 690 | $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | * @return null|string |
| 710 | 710 | */ |
| 711 | 711 | function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') { |
| 712 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_list_authors()' ); |
|
| 712 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_authors()'); |
|
| 713 | 713 | |
| 714 | 714 | $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image'); |
| 715 | 715 | return wp_list_authors($args); |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * @return array |
| 728 | 728 | */ |
| 729 | 729 | function wp_get_post_cats($blogid = '1', $post_ID = 0) { |
| 730 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_get_post_categories()' ); |
|
| 730 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_get_post_categories()'); |
|
| 731 | 731 | return wp_get_post_categories($post_ID); |
| 732 | 732 | } |
| 733 | 733 | |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * @return bool|mixed |
| 746 | 746 | */ |
| 747 | 747 | function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { |
| 748 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_set_post_categories()' ); |
|
| 748 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_set_post_categories()'); |
|
| 749 | 749 | return wp_set_post_categories($post_ID, $post_categories); |
| 750 | 750 | } |
| 751 | 751 | |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param bool $show_post_count |
| 765 | 765 | * @return string|null |
| 766 | 766 | */ |
| 767 | -function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) { |
|
| 768 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_get_archives()' ); |
|
| 767 | +function get_archives($type = '', $limit = '', $format = 'html', $before = '', $after = '', $show_post_count = false) { |
|
| 768 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_get_archives()'); |
|
| 769 | 769 | $args = compact('type', 'limit', 'format', 'before', 'after', 'show_post_count'); |
| 770 | 770 | return wp_get_archives($args); |
| 771 | 771 | } |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | * @return string|null |
| 784 | 784 | */ |
| 785 | 785 | function get_author_link($echo, $author_id, $author_nicename = '') { |
| 786 | - _deprecated_function( __FUNCTION__, '2.1', 'get_author_posts_url()' ); |
|
| 786 | + _deprecated_function(__FUNCTION__, '2.1', 'get_author_posts_url()'); |
|
| 787 | 787 | |
| 788 | 788 | $link = get_author_posts_url($author_id, $author_nicename); |
| 789 | 789 | |
| 790 | - if ( $echo ) |
|
| 790 | + if ($echo) |
|
| 791 | 791 | echo $link; |
| 792 | 792 | return $link; |
| 793 | 793 | } |
@@ -808,9 +808,9 @@ discard block |
||
| 808 | 808 | * @param string $more_file |
| 809 | 809 | * @return string |
| 810 | 810 | */ |
| 811 | -function link_pages($before='<br />', $after='<br />', $next_or_number='number', $nextpagelink='next page', $previouspagelink='previous page', |
|
| 812 | - $pagelink='%', $more_file='') { |
|
| 813 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_link_pages()' ); |
|
| 811 | +function link_pages($before = '<br />', $after = '<br />', $next_or_number = 'number', $nextpagelink = 'next page', $previouspagelink = 'previous page', |
|
| 812 | + $pagelink = '%', $more_file = '') { |
|
| 813 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_link_pages()'); |
|
| 814 | 814 | |
| 815 | 815 | $args = compact('before', 'after', 'next_or_number', 'nextpagelink', 'previouspagelink', 'pagelink', 'more_file'); |
| 816 | 816 | return wp_link_pages($args); |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | * @return string |
| 828 | 828 | */ |
| 829 | 829 | function get_settings($option) { |
| 830 | - _deprecated_function( __FUNCTION__, '2.1', 'get_option()' ); |
|
| 830 | + _deprecated_function(__FUNCTION__, '2.1', 'get_option()'); |
|
| 831 | 831 | |
| 832 | 832 | return get_option($option); |
| 833 | 833 | } |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | * @see the_permalink() |
| 841 | 841 | */ |
| 842 | 842 | function permalink_link() { |
| 843 | - _deprecated_function( __FUNCTION__, '1.2', 'the_permalink()' ); |
|
| 843 | + _deprecated_function(__FUNCTION__, '1.2', 'the_permalink()'); |
|
| 844 | 844 | the_permalink(); |
| 845 | 845 | } |
| 846 | 846 | |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | * @param string $deprecated |
| 855 | 855 | */ |
| 856 | 856 | function permalink_single_rss($deprecated = '') { |
| 857 | - _deprecated_function( __FUNCTION__, '2.3', 'the_permalink_rss()' ); |
|
| 857 | + _deprecated_function(__FUNCTION__, '2.3', 'the_permalink_rss()'); |
|
| 858 | 858 | the_permalink_rss(); |
| 859 | 859 | } |
| 860 | 860 | |
@@ -869,11 +869,11 @@ discard block |
||
| 869 | 869 | * @return null|string |
| 870 | 870 | */ |
| 871 | 871 | function wp_get_links($args = '') { |
| 872 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); |
|
| 872 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()'); |
|
| 873 | 873 | |
| 874 | - if ( strpos( $args, '=' ) === false ) { |
|
| 874 | + if (strpos($args, '=') === false) { |
|
| 875 | 875 | $cat_id = $args; |
| 876 | - $args = add_query_arg( 'category', $cat_id, $args ); |
|
| 876 | + $args = add_query_arg('category', $cat_id, $args); |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | $defaults = array( |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | 'title_li' => '', |
| 893 | 893 | ); |
| 894 | 894 | |
| 895 | - $r = wp_parse_args( $args, $defaults ); |
|
| 895 | + $r = wp_parse_args($args, $defaults); |
|
| 896 | 896 | |
| 897 | 897 | return wp_list_bookmarks($r); |
| 898 | 898 | } |
@@ -923,81 +923,81 @@ discard block |
||
| 923 | 923 | */ |
| 924 | 924 | function get_links($category = -1, $before = '', $after = '<br />', $between = ' ', $show_images = true, $orderby = 'name', |
| 925 | 925 | $show_description = true, $show_rating = false, $limit = -1, $show_updated = 1, $echo = true) { |
| 926 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmarks()' ); |
|
| 926 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmarks()'); |
|
| 927 | 927 | |
| 928 | 928 | $order = 'ASC'; |
| 929 | - if ( substr($orderby, 0, 1) == '_' ) { |
|
| 929 | + if (substr($orderby, 0, 1) == '_') { |
|
| 930 | 930 | $order = 'DESC'; |
| 931 | 931 | $orderby = substr($orderby, 1); |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories |
|
| 934 | + if ($category == -1) //get_bookmarks uses '' to signify all categories |
|
| 935 | 935 | $category = ''; |
| 936 | 936 | |
| 937 | 937 | $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); |
| 938 | 938 | |
| 939 | - if ( !$results ) |
|
| 939 | + if ( ! $results) |
|
| 940 | 940 | return; |
| 941 | 941 | |
| 942 | 942 | $output = ''; |
| 943 | 943 | |
| 944 | - foreach ( (array) $results as $row ) { |
|
| 945 | - if ( !isset($row->recently_updated) ) |
|
| 944 | + foreach ((array) $results as $row) { |
|
| 945 | + if ( ! isset($row->recently_updated)) |
|
| 946 | 946 | $row->recently_updated = false; |
| 947 | 947 | $output .= $before; |
| 948 | - if ( $show_updated && $row->recently_updated ) |
|
| 948 | + if ($show_updated && $row->recently_updated) |
|
| 949 | 949 | $output .= get_option('links_recently_updated_prepend'); |
| 950 | 950 | $the_link = '#'; |
| 951 | - if ( !empty($row->link_url) ) |
|
| 951 | + if ( ! empty($row->link_url)) |
|
| 952 | 952 | $the_link = esc_url($row->link_url); |
| 953 | 953 | $rel = $row->link_rel; |
| 954 | - if ( '' != $rel ) |
|
| 955 | - $rel = ' rel="' . $rel . '"'; |
|
| 954 | + if ('' != $rel) |
|
| 955 | + $rel = ' rel="'.$rel.'"'; |
|
| 956 | 956 | |
| 957 | 957 | $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); |
| 958 | 958 | $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); |
| 959 | 959 | $title = $desc; |
| 960 | 960 | |
| 961 | - if ( $show_updated ) |
|
| 961 | + if ($show_updated) |
|
| 962 | 962 | if (substr($row->link_updated_f, 0, 2) != '00') |
| 963 | - $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; |
|
| 963 | + $title .= ' ('.__('Last updated').' '.date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)).')'; |
|
| 964 | 964 | |
| 965 | - if ( '' != $title ) |
|
| 966 | - $title = ' title="' . $title . '"'; |
|
| 965 | + if ('' != $title) |
|
| 966 | + $title = ' title="'.$title.'"'; |
|
| 967 | 967 | |
| 968 | - $alt = ' alt="' . $name . '"'; |
|
| 968 | + $alt = ' alt="'.$name.'"'; |
|
| 969 | 969 | |
| 970 | 970 | $target = $row->link_target; |
| 971 | - if ( '' != $target ) |
|
| 972 | - $target = ' target="' . $target . '"'; |
|
| 971 | + if ('' != $target) |
|
| 972 | + $target = ' target="'.$target.'"'; |
|
| 973 | 973 | |
| 974 | - $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; |
|
| 974 | + $output .= '<a href="'.$the_link.'"'.$rel.$title.$target.'>'; |
|
| 975 | 975 | |
| 976 | - if ( $row->link_image != null && $show_images ) { |
|
| 977 | - if ( strpos($row->link_image, 'http') !== false ) |
|
| 976 | + if ($row->link_image != null && $show_images) { |
|
| 977 | + if (strpos($row->link_image, 'http') !== false) |
|
| 978 | 978 | $output .= "<img src=\"$row->link_image\" $alt $title />"; |
| 979 | 979 | else // If it's a relative path |
| 980 | - $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; |
|
| 980 | + $output .= "<img src=\"".get_option('siteurl')."$row->link_image\" $alt $title />"; |
|
| 981 | 981 | } else { |
| 982 | 982 | $output .= $name; |
| 983 | 983 | } |
| 984 | 984 | |
| 985 | 985 | $output .= '</a>'; |
| 986 | 986 | |
| 987 | - if ( $show_updated && $row->recently_updated ) |
|
| 987 | + if ($show_updated && $row->recently_updated) |
|
| 988 | 988 | $output .= get_option('links_recently_updated_append'); |
| 989 | 989 | |
| 990 | - if ( $show_description && '' != $desc ) |
|
| 991 | - $output .= $between . $desc; |
|
| 990 | + if ($show_description && '' != $desc) |
|
| 991 | + $output .= $between.$desc; |
|
| 992 | 992 | |
| 993 | 993 | if ($show_rating) { |
| 994 | - $output .= $between . get_linkrating($row); |
|
| 994 | + $output .= $between.get_linkrating($row); |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | $output .= "$after\n"; |
| 998 | 998 | } // end while |
| 999 | 999 | |
| 1000 | - if ( !$echo ) |
|
| 1000 | + if ( ! $echo) |
|
| 1001 | 1001 | return $output; |
| 1002 | 1002 | echo $output; |
| 1003 | 1003 | } |
@@ -1015,29 +1015,29 @@ discard block |
||
| 1015 | 1015 | * @param string $order Sort link categories by 'name' or 'id' |
| 1016 | 1016 | */ |
| 1017 | 1017 | function get_links_list($order = 'name') { |
| 1018 | - _deprecated_function( __FUNCTION__, '2.1', 'wp_list_bookmarks()' ); |
|
| 1018 | + _deprecated_function(__FUNCTION__, '2.1', 'wp_list_bookmarks()'); |
|
| 1019 | 1019 | |
| 1020 | 1020 | $order = strtolower($order); |
| 1021 | 1021 | |
| 1022 | 1022 | // Handle link category sorting |
| 1023 | 1023 | $direction = 'ASC'; |
| 1024 | - if ( '_' == substr($order,0,1) ) { |
|
| 1024 | + if ('_' == substr($order, 0, 1)) { |
|
| 1025 | 1025 | $direction = 'DESC'; |
| 1026 | - $order = substr($order,1); |
|
| 1026 | + $order = substr($order, 1); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | - if ( !isset($direction) ) |
|
| 1029 | + if ( ! isset($direction)) |
|
| 1030 | 1030 | $direction = ''; |
| 1031 | 1031 | |
| 1032 | 1032 | $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); |
| 1033 | 1033 | |
| 1034 | 1034 | // Display each category |
| 1035 | - if ( $cats ) { |
|
| 1036 | - foreach ( (array) $cats as $cat ) { |
|
| 1035 | + if ($cats) { |
|
| 1036 | + foreach ((array) $cats as $cat) { |
|
| 1037 | 1037 | // Handle each category. |
| 1038 | 1038 | |
| 1039 | 1039 | // Display the category name |
| 1040 | - echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; |
|
| 1040 | + echo ' <li id="linkcat-'.$cat->term_id.'" class="linkcat"><h2>'.apply_filters('link_category', $cat->name)."</h2>\n\t<ul>\n"; |
|
| 1041 | 1041 | // Call get_links() with all the appropriate params |
| 1042 | 1042 | get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); |
| 1043 | 1043 | |
@@ -1059,8 +1059,8 @@ discard block |
||
| 1059 | 1059 | * @param string $file the page to open in the popup window |
| 1060 | 1060 | * @param bool $count the number of links in the db |
| 1061 | 1061 | */ |
| 1062 | -function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { |
|
| 1063 | - _deprecated_function( __FUNCTION__, '2.1' ); |
|
| 1062 | +function links_popup_script($text = 'Links', $width = 400, $height = 400, $file = 'links.all.php', $count = true) { |
|
| 1063 | + _deprecated_function(__FUNCTION__, '2.1'); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | /** |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | * @return mixed |
| 1073 | 1073 | */ |
| 1074 | 1074 | function get_linkrating($link) { |
| 1075 | - _deprecated_function( __FUNCTION__, '2.1', 'sanitize_bookmark_field()' ); |
|
| 1075 | + _deprecated_function(__FUNCTION__, '2.1', 'sanitize_bookmark_field()'); |
|
| 1076 | 1076 | return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); |
| 1077 | 1077 | } |
| 1078 | 1078 | |
@@ -1087,16 +1087,16 @@ discard block |
||
| 1087 | 1087 | * @return string |
| 1088 | 1088 | */ |
| 1089 | 1089 | function get_linkcatname($id = 0) { |
| 1090 | - _deprecated_function( __FUNCTION__, '2.1', 'get_category()' ); |
|
| 1090 | + _deprecated_function(__FUNCTION__, '2.1', 'get_category()'); |
|
| 1091 | 1091 | |
| 1092 | 1092 | $id = (int) $id; |
| 1093 | 1093 | |
| 1094 | - if ( empty($id) ) |
|
| 1094 | + if (empty($id)) |
|
| 1095 | 1095 | return ''; |
| 1096 | 1096 | |
| 1097 | 1097 | $cats = wp_get_link_cats($id); |
| 1098 | 1098 | |
| 1099 | - if ( empty($cats) || ! is_array($cats) ) |
|
| 1099 | + if (empty($cats) || ! is_array($cats)) |
|
| 1100 | 1100 | return ''; |
| 1101 | 1101 | |
| 1102 | 1102 | $cat_id = (int) $cats[0]; // Take the first cat. |
@@ -1115,7 +1115,7 @@ discard block |
||
| 1115 | 1115 | * @param string $link_text |
| 1116 | 1116 | */ |
| 1117 | 1117 | function comments_rss_link($link_text = 'Comments RSS') { |
| 1118 | - _deprecated_function( __FUNCTION__, '2.5', 'post_comments_feed_link()' ); |
|
| 1118 | + _deprecated_function(__FUNCTION__, '2.5', 'post_comments_feed_link()'); |
|
| 1119 | 1119 | post_comments_feed_link($link_text); |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -1131,11 +1131,11 @@ discard block |
||
| 1131 | 1131 | * @return string |
| 1132 | 1132 | */ |
| 1133 | 1133 | function get_category_rss_link($echo = false, $cat_ID = 1) { |
| 1134 | - _deprecated_function( __FUNCTION__, '2.5', 'get_category_feed_link()' ); |
|
| 1134 | + _deprecated_function(__FUNCTION__, '2.5', 'get_category_feed_link()'); |
|
| 1135 | 1135 | |
| 1136 | 1136 | $link = get_category_feed_link($cat_ID, 'rss2'); |
| 1137 | 1137 | |
| 1138 | - if ( $echo ) |
|
| 1138 | + if ($echo) |
|
| 1139 | 1139 | echo $link; |
| 1140 | 1140 | return $link; |
| 1141 | 1141 | } |
@@ -1152,10 +1152,10 @@ discard block |
||
| 1152 | 1152 | * @return string |
| 1153 | 1153 | */ |
| 1154 | 1154 | function get_author_rss_link($echo = false, $author_id = 1) { |
| 1155 | - _deprecated_function( __FUNCTION__, '2.5', 'get_author_feed_link()' ); |
|
| 1155 | + _deprecated_function(__FUNCTION__, '2.5', 'get_author_feed_link()'); |
|
| 1156 | 1156 | |
| 1157 | 1157 | $link = get_author_feed_link($author_id); |
| 1158 | - if ( $echo ) |
|
| 1158 | + if ($echo) |
|
| 1159 | 1159 | echo $link; |
| 1160 | 1160 | return $link; |
| 1161 | 1161 | } |
@@ -1170,8 +1170,8 @@ discard block |
||
| 1170 | 1170 | * @return string |
| 1171 | 1171 | */ |
| 1172 | 1172 | function comments_rss() { |
| 1173 | - _deprecated_function( __FUNCTION__, '2.2', 'get_post_comments_feed_link()' ); |
|
| 1174 | - return esc_url( get_post_comments_feed_link() ); |
|
| 1173 | + _deprecated_function(__FUNCTION__, '2.2', 'get_post_comments_feed_link()'); |
|
| 1174 | + return esc_url(get_post_comments_feed_link()); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | * @return int The new user's ID. |
| 1188 | 1188 | */ |
| 1189 | 1189 | function create_user($username, $password, $email) { |
| 1190 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_create_user()' ); |
|
| 1190 | + _deprecated_function(__FUNCTION__, '2.0', 'wp_create_user()'); |
|
| 1191 | 1191 | return wp_create_user($username, $password, $email); |
| 1192 | 1192 | } |
| 1193 | 1193 | |
@@ -1197,7 +1197,7 @@ discard block |
||
| 1197 | 1197 | * @deprecated 2.5.0 |
| 1198 | 1198 | */ |
| 1199 | 1199 | function gzip_compression() { |
| 1200 | - _deprecated_function( __FUNCTION__, '2.5' ); |
|
| 1200 | + _deprecated_function(__FUNCTION__, '2.5'); |
|
| 1201 | 1201 | return false; |
| 1202 | 1202 | } |
| 1203 | 1203 | |
@@ -1213,8 +1213,8 @@ discard block |
||
| 1213 | 1213 | * @param bool $include_unapproved Whether to include unapproved comments |
| 1214 | 1214 | * @return array The comment data |
| 1215 | 1215 | */ |
| 1216 | -function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { |
|
| 1217 | - _deprecated_function( __FUNCTION__, '2.7', 'get_comment()' ); |
|
| 1216 | +function get_commentdata($comment_ID, $no_cache = 0, $include_unapproved = false) { |
|
| 1217 | + _deprecated_function(__FUNCTION__, '2.7', 'get_comment()'); |
|
| 1218 | 1218 | return get_comment($comment_ID, ARRAY_A); |
| 1219 | 1219 | } |
| 1220 | 1220 | |
@@ -1228,9 +1228,9 @@ discard block |
||
| 1228 | 1228 | * @param int $cat_ID Category ID |
| 1229 | 1229 | * @return string category name |
| 1230 | 1230 | */ |
| 1231 | -function get_catname( $cat_ID ) { |
|
| 1232 | - _deprecated_function( __FUNCTION__, '2.8', 'get_cat_name()' ); |
|
| 1233 | - return get_cat_name( $cat_ID ); |
|
| 1231 | +function get_catname($cat_ID) { |
|
| 1232 | + _deprecated_function(__FUNCTION__, '2.8', 'get_cat_name()'); |
|
| 1233 | + return get_cat_name($cat_ID); |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | 1236 | /** |
@@ -1246,25 +1246,25 @@ discard block |
||
| 1246 | 1246 | * @param array $visited Optional. Category Term IDs that have already been added. |
| 1247 | 1247 | * @return string |
| 1248 | 1248 | */ |
| 1249 | -function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { |
|
| 1250 | - _deprecated_function( __FUNCTION__, '2.8', 'get_term_children()' ); |
|
| 1251 | - if ( 0 == $id ) |
|
| 1249 | +function get_category_children($id, $before = '/', $after = '', $visited = array()) { |
|
| 1250 | + _deprecated_function(__FUNCTION__, '2.8', 'get_term_children()'); |
|
| 1251 | + if (0 == $id) |
|
| 1252 | 1252 | return ''; |
| 1253 | 1253 | |
| 1254 | 1254 | $chain = ''; |
| 1255 | 1255 | /** TODO: consult hierarchy */ |
| 1256 | 1256 | $cat_ids = get_all_category_ids(); |
| 1257 | - foreach ( (array) $cat_ids as $cat_id ) { |
|
| 1258 | - if ( $cat_id == $id ) |
|
| 1257 | + foreach ((array) $cat_ids as $cat_id) { |
|
| 1258 | + if ($cat_id == $id) |
|
| 1259 | 1259 | continue; |
| 1260 | 1260 | |
| 1261 | - $category = get_category( $cat_id ); |
|
| 1262 | - if ( is_wp_error( $category ) ) |
|
| 1261 | + $category = get_category($cat_id); |
|
| 1262 | + if (is_wp_error($category)) |
|
| 1263 | 1263 | return $category; |
| 1264 | - if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
|
| 1264 | + if ($category->parent == $id && ! in_array($category->term_id, $visited)) { |
|
| 1265 | 1265 | $visited[] = $category->term_id; |
| 1266 | 1266 | $chain .= $before.$category->term_id.$after; |
| 1267 | - $chain .= get_category_children( $category->term_id, $before, $after ); |
|
| 1267 | + $chain .= get_category_children($category->term_id, $before, $after); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | } |
| 1270 | 1270 | return $chain; |
@@ -1282,11 +1282,11 @@ discard block |
||
| 1282 | 1282 | * @return object List of all of the category IDs. |
| 1283 | 1283 | */ |
| 1284 | 1284 | function get_all_category_ids() { |
| 1285 | - _deprecated_function( __FUNCTION__, '4.0', 'get_terms()' ); |
|
| 1285 | + _deprecated_function(__FUNCTION__, '4.0', 'get_terms()'); |
|
| 1286 | 1286 | |
| 1287 | - if ( ! $cat_ids = wp_cache_get( 'all_category_ids', 'category' ) ) { |
|
| 1288 | - $cat_ids = get_terms( 'category', array('fields' => 'ids', 'get' => 'all') ); |
|
| 1289 | - wp_cache_add( 'all_category_ids', $cat_ids, 'category' ); |
|
| 1287 | + if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category')) { |
|
| 1288 | + $cat_ids = get_terms('category', array('fields' => 'ids', 'get' => 'all')); |
|
| 1289 | + wp_cache_add('all_category_ids', $cat_ids, 'category'); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | return $cat_ids; |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | * @return string The author's description. |
| 1303 | 1303 | */ |
| 1304 | 1304 | function get_the_author_description() { |
| 1305 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' ); |
|
| 1305 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'description\')'); |
|
| 1306 | 1306 | return get_the_author_meta('description'); |
| 1307 | 1307 | } |
| 1308 | 1308 | |
@@ -1314,7 +1314,7 @@ discard block |
||
| 1314 | 1314 | * @see the_author_meta() |
| 1315 | 1315 | */ |
| 1316 | 1316 | function the_author_description() { |
| 1317 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' ); |
|
| 1317 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'description\')'); |
|
| 1318 | 1318 | the_author_meta('description'); |
| 1319 | 1319 | } |
| 1320 | 1320 | |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | * @return string The author's login name (username). |
| 1329 | 1329 | */ |
| 1330 | 1330 | function get_the_author_login() { |
| 1331 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' ); |
|
| 1331 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'login\')'); |
|
| 1332 | 1332 | return get_the_author_meta('login'); |
| 1333 | 1333 | } |
| 1334 | 1334 | |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | * @see the_author_meta() |
| 1341 | 1341 | */ |
| 1342 | 1342 | function the_author_login() { |
| 1343 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' ); |
|
| 1343 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'login\')'); |
|
| 1344 | 1344 | the_author_meta('login'); |
| 1345 | 1345 | } |
| 1346 | 1346 | |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | * @return string The author's first name. |
| 1355 | 1355 | */ |
| 1356 | 1356 | function get_the_author_firstname() { |
| 1357 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' ); |
|
| 1357 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')'); |
|
| 1358 | 1358 | return get_the_author_meta('first_name'); |
| 1359 | 1359 | } |
| 1360 | 1360 | |
@@ -1366,7 +1366,7 @@ discard block |
||
| 1366 | 1366 | * @see the_author_meta() |
| 1367 | 1367 | */ |
| 1368 | 1368 | function the_author_firstname() { |
| 1369 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' ); |
|
| 1369 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'first_name\')'); |
|
| 1370 | 1370 | the_author_meta('first_name'); |
| 1371 | 1371 | } |
| 1372 | 1372 | |
@@ -1380,7 +1380,7 @@ discard block |
||
| 1380 | 1380 | * @return string The author's last name. |
| 1381 | 1381 | */ |
| 1382 | 1382 | function get_the_author_lastname() { |
| 1383 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' ); |
|
| 1383 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')'); |
|
| 1384 | 1384 | return get_the_author_meta('last_name'); |
| 1385 | 1385 | } |
| 1386 | 1386 | |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | * @see the_author_meta() |
| 1393 | 1393 | */ |
| 1394 | 1394 | function the_author_lastname() { |
| 1395 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' ); |
|
| 1395 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'last_name\')'); |
|
| 1396 | 1396 | the_author_meta('last_name'); |
| 1397 | 1397 | } |
| 1398 | 1398 | |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | * @return string The author's nickname. |
| 1407 | 1407 | */ |
| 1408 | 1408 | function get_the_author_nickname() { |
| 1409 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' ); |
|
| 1409 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')'); |
|
| 1410 | 1410 | return get_the_author_meta('nickname'); |
| 1411 | 1411 | } |
| 1412 | 1412 | |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | * @see the_author_meta() |
| 1419 | 1419 | */ |
| 1420 | 1420 | function the_author_nickname() { |
| 1421 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' ); |
|
| 1421 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'nickname\')'); |
|
| 1422 | 1422 | the_author_meta('nickname'); |
| 1423 | 1423 | } |
| 1424 | 1424 | |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | * @return string The author's username. |
| 1433 | 1433 | */ |
| 1434 | 1434 | function get_the_author_email() { |
| 1435 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' ); |
|
| 1435 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'email\')'); |
|
| 1436 | 1436 | return get_the_author_meta('email'); |
| 1437 | 1437 | } |
| 1438 | 1438 | |
@@ -1444,7 +1444,7 @@ discard block |
||
| 1444 | 1444 | * @see the_author_meta() |
| 1445 | 1445 | */ |
| 1446 | 1446 | function the_author_email() { |
| 1447 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' ); |
|
| 1447 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'email\')'); |
|
| 1448 | 1448 | the_author_meta('email'); |
| 1449 | 1449 | } |
| 1450 | 1450 | |
@@ -1458,7 +1458,7 @@ discard block |
||
| 1458 | 1458 | * @return string The author's ICQ number. |
| 1459 | 1459 | */ |
| 1460 | 1460 | function get_the_author_icq() { |
| 1461 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' ); |
|
| 1461 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')'); |
|
| 1462 | 1462 | return get_the_author_meta('icq'); |
| 1463 | 1463 | } |
| 1464 | 1464 | |
@@ -1470,7 +1470,7 @@ discard block |
||
| 1470 | 1470 | * @see the_author_meta() |
| 1471 | 1471 | */ |
| 1472 | 1472 | function the_author_icq() { |
| 1473 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' ); |
|
| 1473 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'icq\')'); |
|
| 1474 | 1474 | the_author_meta('icq'); |
| 1475 | 1475 | } |
| 1476 | 1476 | |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | * @return string The author's Yahoo! IM name. |
| 1485 | 1485 | */ |
| 1486 | 1486 | function get_the_author_yim() { |
| 1487 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' ); |
|
| 1487 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')'); |
|
| 1488 | 1488 | return get_the_author_meta('yim'); |
| 1489 | 1489 | } |
| 1490 | 1490 | |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | * @see the_author_meta() |
| 1497 | 1497 | */ |
| 1498 | 1498 | function the_author_yim() { |
| 1499 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' ); |
|
| 1499 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'yim\')'); |
|
| 1500 | 1500 | the_author_meta('yim'); |
| 1501 | 1501 | } |
| 1502 | 1502 | |
@@ -1510,7 +1510,7 @@ discard block |
||
| 1510 | 1510 | * @return string The author's MSN address. |
| 1511 | 1511 | */ |
| 1512 | 1512 | function get_the_author_msn() { |
| 1513 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' ); |
|
| 1513 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')'); |
|
| 1514 | 1514 | return get_the_author_meta('msn'); |
| 1515 | 1515 | } |
| 1516 | 1516 | |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | * @see the_author_meta() |
| 1523 | 1523 | */ |
| 1524 | 1524 | function the_author_msn() { |
| 1525 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' ); |
|
| 1525 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'msn\')'); |
|
| 1526 | 1526 | the_author_meta('msn'); |
| 1527 | 1527 | } |
| 1528 | 1528 | |
@@ -1536,7 +1536,7 @@ discard block |
||
| 1536 | 1536 | * @return string The author's AIM address. |
| 1537 | 1537 | */ |
| 1538 | 1538 | function get_the_author_aim() { |
| 1539 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')' ); |
|
| 1539 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')'); |
|
| 1540 | 1540 | return get_the_author_meta('aim'); |
| 1541 | 1541 | } |
| 1542 | 1542 | |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | * @see the_author_meta() |
| 1549 | 1549 | */ |
| 1550 | 1550 | function the_author_aim() { |
| 1551 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' ); |
|
| 1551 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'aim\')'); |
|
| 1552 | 1552 | the_author_meta('aim'); |
| 1553 | 1553 | } |
| 1554 | 1554 | |
@@ -1562,8 +1562,8 @@ discard block |
||
| 1562 | 1562 | * @param int $auth_id The ID of the author. |
| 1563 | 1563 | * @return string The author's display name. |
| 1564 | 1564 | */ |
| 1565 | -function get_author_name( $auth_id = false ) { |
|
| 1566 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' ); |
|
| 1565 | +function get_author_name($auth_id = false) { |
|
| 1566 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')'); |
|
| 1567 | 1567 | return get_the_author_meta('display_name', $auth_id); |
| 1568 | 1568 | } |
| 1569 | 1569 | |
@@ -1577,7 +1577,7 @@ discard block |
||
| 1577 | 1577 | * @return string The URL to the author's page. |
| 1578 | 1578 | */ |
| 1579 | 1579 | function get_the_author_url() { |
| 1580 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' ); |
|
| 1580 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'url\')'); |
|
| 1581 | 1581 | return get_the_author_meta('url'); |
| 1582 | 1582 | } |
| 1583 | 1583 | |
@@ -1589,7 +1589,7 @@ discard block |
||
| 1589 | 1589 | * @see the_author_meta() |
| 1590 | 1590 | */ |
| 1591 | 1591 | function the_author_url() { |
| 1592 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' ); |
|
| 1592 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'url\')'); |
|
| 1593 | 1593 | the_author_meta('url'); |
| 1594 | 1594 | } |
| 1595 | 1595 | |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | * @return string|int The author's ID. |
| 1604 | 1604 | */ |
| 1605 | 1605 | function get_the_author_ID() { |
| 1606 | - _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' ); |
|
| 1606 | + _deprecated_function(__FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')'); |
|
| 1607 | 1607 | return get_the_author_meta('ID'); |
| 1608 | 1608 | } |
| 1609 | 1609 | |
@@ -1615,7 +1615,7 @@ discard block |
||
| 1615 | 1615 | * @see the_author_meta() |
| 1616 | 1616 | */ |
| 1617 | 1617 | function the_author_ID() { |
| 1618 | - _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' ); |
|
| 1618 | + _deprecated_function(__FUNCTION__, '2.8', 'the_author_meta(\'ID\')'); |
|
| 1619 | 1619 | the_author_meta('ID'); |
| 1620 | 1620 | } |
| 1621 | 1621 | |
@@ -1647,23 +1647,23 @@ discard block |
||
| 1647 | 1647 | * @param int $cut Optional. Amount of words to keep for the content. |
| 1648 | 1648 | * @param int $encode_html Optional. How to encode the content. |
| 1649 | 1649 | */ |
| 1650 | -function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { |
|
| 1651 | - _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' ); |
|
| 1650 | +function the_content_rss($more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $cut = 0, $encode_html = 0) { |
|
| 1651 | + _deprecated_function(__FUNCTION__, '2.9', 'the_content_feed'); |
|
| 1652 | 1652 | $content = get_the_content($more_link_text, $stripteaser); |
| 1653 | 1653 | $content = apply_filters('the_content_rss', $content); |
| 1654 | - if ( $cut && !$encode_html ) |
|
| 1654 | + if ($cut && ! $encode_html) |
|
| 1655 | 1655 | $encode_html = 2; |
| 1656 | - if ( 1== $encode_html ) { |
|
| 1656 | + if (1 == $encode_html) { |
|
| 1657 | 1657 | $content = esc_html($content); |
| 1658 | 1658 | $cut = 0; |
| 1659 | - } elseif ( 0 == $encode_html ) { |
|
| 1659 | + } elseif (0 == $encode_html) { |
|
| 1660 | 1660 | $content = make_url_footnote($content); |
| 1661 | - } elseif ( 2 == $encode_html ) { |
|
| 1661 | + } elseif (2 == $encode_html) { |
|
| 1662 | 1662 | $content = strip_tags($content); |
| 1663 | 1663 | } |
| 1664 | - if ( $cut ) { |
|
| 1664 | + if ($cut) { |
|
| 1665 | 1665 | $blah = explode(' ', $content); |
| 1666 | - if ( count($blah) > $cut ) { |
|
| 1666 | + if (count($blah) > $cut) { |
|
| 1667 | 1667 | $k = $cut; |
| 1668 | 1668 | $use_dotdotdot = 1; |
| 1669 | 1669 | } else { |
@@ -1672,7 +1672,7 @@ discard block |
||
| 1672 | 1672 | } |
| 1673 | 1673 | |
| 1674 | 1674 | /** @todo Check performance, might be faster to use array slice instead. */ |
| 1675 | - for ( $i=0; $i<$k; $i++ ) |
|
| 1675 | + for ($i = 0; $i < $k; $i++) |
|
| 1676 | 1676 | $excerpt .= $blah[$i].' '; |
| 1677 | 1677 | $excerpt .= ($use_dotdotdot) ? '...' : ''; |
| 1678 | 1678 | $content = $excerpt; |
@@ -1693,20 +1693,20 @@ discard block |
||
| 1693 | 1693 | * @param string $content Content to get links |
| 1694 | 1694 | * @return string HTML stripped out of content with links at the bottom. |
| 1695 | 1695 | */ |
| 1696 | -function make_url_footnote( $content ) { |
|
| 1697 | - _deprecated_function( __FUNCTION__, '2.9', '' ); |
|
| 1698 | - preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); |
|
| 1696 | +function make_url_footnote($content) { |
|
| 1697 | + _deprecated_function(__FUNCTION__, '2.9', ''); |
|
| 1698 | + preg_match_all('/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches); |
|
| 1699 | 1699 | $links_summary = "\n"; |
| 1700 | - for ( $i = 0, $c = count( $matches[0] ); $i < $c; $i++ ) { |
|
| 1700 | + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { |
|
| 1701 | 1701 | $link_match = $matches[0][$i]; |
| 1702 | - $link_number = '['.($i+1).']'; |
|
| 1702 | + $link_number = '['.($i + 1).']'; |
|
| 1703 | 1703 | $link_url = $matches[2][$i]; |
| 1704 | 1704 | $link_text = $matches[4][$i]; |
| 1705 | - $content = str_replace( $link_match, $link_text . ' ' . $link_number, $content ); |
|
| 1706 | - $link_url = ( ( strtolower( substr( $link_url, 0, 7 ) ) != 'http://' ) && ( strtolower( substr( $link_url, 0, 8 ) ) != 'https://' ) ) ? get_option( 'home' ) . $link_url : $link_url; |
|
| 1707 | - $links_summary .= "\n" . $link_number . ' ' . $link_url; |
|
| 1705 | + $content = str_replace($link_match, $link_text.' '.$link_number, $content); |
|
| 1706 | + $link_url = ((strtolower(substr($link_url, 0, 7)) != 'http://') && (strtolower(substr($link_url, 0, 8)) != 'https://')) ? get_option('home').$link_url : $link_url; |
|
| 1707 | + $links_summary .= "\n".$link_number.' '.$link_url; |
|
| 1708 | 1708 | } |
| 1709 | - $content = strip_tags( $content ); |
|
| 1709 | + $content = strip_tags($content); |
|
| 1710 | 1710 | $content .= $links_summary; |
| 1711 | 1711 | return $content; |
| 1712 | 1712 | } |
@@ -1732,9 +1732,9 @@ discard block |
||
| 1732 | 1732 | * @param string $domain Optional. Domain to retrieve the translated text |
| 1733 | 1733 | * @return string Translated context string without pipe |
| 1734 | 1734 | */ |
| 1735 | -function _c( $text, $domain = 'default' ) { |
|
| 1736 | - _deprecated_function( __FUNCTION__, '2.9', '_x()' ); |
|
| 1737 | - return before_last_bar( translate( $text, $domain ) ); |
|
| 1735 | +function _c($text, $domain = 'default') { |
|
| 1736 | + _deprecated_function(__FUNCTION__, '2.9', '_x()'); |
|
| 1737 | + return before_last_bar(translate($text, $domain)); |
|
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | 1740 | /** |
@@ -1749,9 +1749,9 @@ discard block |
||
| 1749 | 1749 | * @param string $domain Domain to retrieve the translated text |
| 1750 | 1750 | * @return string Translated text |
| 1751 | 1751 | */ |
| 1752 | -function translate_with_context( $text, $domain = 'default' ) { |
|
| 1753 | - _deprecated_function( __FUNCTION__, '2.9', '_x()' ); |
|
| 1754 | - return before_last_bar( translate( $text, $domain ) ); |
|
| 1752 | +function translate_with_context($text, $domain = 'default') { |
|
| 1753 | + _deprecated_function(__FUNCTION__, '2.9', '_x()'); |
|
| 1754 | + return before_last_bar(translate($text, $domain)); |
|
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | /** |
@@ -1762,9 +1762,9 @@ discard block |
||
| 1762 | 1762 | * @deprecated 3.0.0 Use _nx() |
| 1763 | 1763 | * @see _nx() |
| 1764 | 1764 | */ |
| 1765 | -function _nc( $single, $plural, $number, $domain = 'default' ) { |
|
| 1766 | - _deprecated_function( __FUNCTION__, '2.9', '_nx()' ); |
|
| 1767 | - return before_last_bar( _n( $single, $plural, $number, $domain ) ); |
|
| 1765 | +function _nc($single, $plural, $number, $domain = 'default') { |
|
| 1766 | + _deprecated_function(__FUNCTION__, '2.9', '_nx()'); |
|
| 1767 | + return before_last_bar(_n($single, $plural, $number, $domain)); |
|
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | /** |
@@ -1775,7 +1775,7 @@ discard block |
||
| 1775 | 1775 | * @see _n() |
| 1776 | 1776 | */ |
| 1777 | 1777 | function __ngettext() { |
| 1778 | - _deprecated_function( __FUNCTION__, '2.8', '_n()' ); |
|
| 1778 | + _deprecated_function(__FUNCTION__, '2.8', '_n()'); |
|
| 1779 | 1779 | $args = func_get_args(); |
| 1780 | 1780 | return call_user_func_array('_n', $args); |
| 1781 | 1781 | } |
@@ -1788,7 +1788,7 @@ discard block |
||
| 1788 | 1788 | * @see _n_noop() |
| 1789 | 1789 | */ |
| 1790 | 1790 | function __ngettext_noop() { |
| 1791 | - _deprecated_function( __FUNCTION__, '2.8', '_n_noop()' ); |
|
| 1791 | + _deprecated_function(__FUNCTION__, '2.8', '_n_noop()'); |
|
| 1792 | 1792 | $args = func_get_args(); |
| 1793 | 1793 | return call_user_func_array('_n_noop', $args); |
| 1794 | 1794 | |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | * @return array List of all options. |
| 1805 | 1805 | */ |
| 1806 | 1806 | function get_alloptions() { |
| 1807 | - _deprecated_function( __FUNCTION__, '3.0', 'wp_load_alloptions()' ); |
|
| 1807 | + _deprecated_function(__FUNCTION__, '3.0', 'wp_load_alloptions()'); |
|
| 1808 | 1808 | return wp_load_alloptions(); |
| 1809 | 1809 | } |
| 1810 | 1810 | |
@@ -1822,14 +1822,14 @@ discard block |
||
| 1822 | 1822 | * @return string |
| 1823 | 1823 | */ |
| 1824 | 1824 | function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { |
| 1825 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' ); |
|
| 1825 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_link()'); |
|
| 1826 | 1826 | $id = (int) $id; |
| 1827 | 1827 | $_post = get_post($id); |
| 1828 | 1828 | |
| 1829 | - if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) |
|
| 1829 | + if (('attachment' != $_post->post_type) || ! $url = wp_get_attachment_url($_post->ID)) |
|
| 1830 | 1830 | return __('Missing Attachment'); |
| 1831 | 1831 | |
| 1832 | - if ( $permalink ) |
|
| 1832 | + if ($permalink) |
|
| 1833 | 1833 | $url = get_attachment_link($_post->ID); |
| 1834 | 1834 | |
| 1835 | 1835 | $post_title = esc_attr($_post->post_title); |
@@ -1849,31 +1849,31 @@ discard block |
||
| 1849 | 1849 | * @param bool $fullsize Optional, default to false. Whether to have full image. |
| 1850 | 1850 | * @return array Icon URL and full path to file, respectively. |
| 1851 | 1851 | */ |
| 1852 | -function get_attachment_icon_src( $id = 0, $fullsize = false ) { |
|
| 1853 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); |
|
| 1852 | +function get_attachment_icon_src($id = 0, $fullsize = false) { |
|
| 1853 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_image_src()'); |
|
| 1854 | 1854 | $id = (int) $id; |
| 1855 | - if ( !$post = get_post($id) ) |
|
| 1855 | + if ( ! $post = get_post($id)) |
|
| 1856 | 1856 | return false; |
| 1857 | 1857 | |
| 1858 | - $file = get_attached_file( $post->ID ); |
|
| 1858 | + $file = get_attached_file($post->ID); |
|
| 1859 | 1859 | |
| 1860 | - if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { |
|
| 1860 | + if ( ! $fullsize && $src = wp_get_attachment_thumb_url($post->ID)) { |
|
| 1861 | 1861 | // We have a thumbnail desired, specified and existing |
| 1862 | 1862 | |
| 1863 | 1863 | $src_file = basename($src); |
| 1864 | - } elseif ( wp_attachment_is_image( $post->ID ) ) { |
|
| 1864 | + } elseif (wp_attachment_is_image($post->ID)) { |
|
| 1865 | 1865 | // We have an image without a thumbnail |
| 1866 | 1866 | |
| 1867 | - $src = wp_get_attachment_url( $post->ID ); |
|
| 1867 | + $src = wp_get_attachment_url($post->ID); |
|
| 1868 | 1868 | $src_file = & $file; |
| 1869 | - } elseif ( $src = wp_mime_type_icon( $post->ID ) ) { |
|
| 1869 | + } elseif ($src = wp_mime_type_icon($post->ID)) { |
|
| 1870 | 1870 | // No thumb, no image. We'll look for a mime-related icon instead. |
| 1871 | 1871 | |
| 1872 | - $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' ); |
|
| 1873 | - $src_file = $icon_dir . '/' . basename($src); |
|
| 1872 | + $icon_dir = apply_filters('icon_dir', get_template_directory().'/images'); |
|
| 1873 | + $src_file = $icon_dir.'/'.basename($src); |
|
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | - if ( !isset($src) || !$src ) |
|
| 1876 | + if ( ! isset($src) || ! $src) |
|
| 1877 | 1877 | return false; |
| 1878 | 1878 | |
| 1879 | 1879 | return array($src, $src_file); |
@@ -1891,27 +1891,27 @@ discard block |
||
| 1891 | 1891 | * @param array $max_dims Optional. Dimensions of image. |
| 1892 | 1892 | * @return false|string HTML content. |
| 1893 | 1893 | */ |
| 1894 | -function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { |
|
| 1895 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); |
|
| 1894 | +function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) { |
|
| 1895 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_image()'); |
|
| 1896 | 1896 | $id = (int) $id; |
| 1897 | - if ( !$post = get_post($id) ) |
|
| 1897 | + if ( ! $post = get_post($id)) |
|
| 1898 | 1898 | return false; |
| 1899 | 1899 | |
| 1900 | - if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) |
|
| 1900 | + if ( ! $src = get_attachment_icon_src($post->ID, $fullsize)) |
|
| 1901 | 1901 | return false; |
| 1902 | 1902 | |
| 1903 | 1903 | list($src, $src_file) = $src; |
| 1904 | 1904 | |
| 1905 | 1905 | // Do we need to constrain the image? |
| 1906 | - if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) { |
|
| 1906 | + if (($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file)) { |
|
| 1907 | 1907 | |
| 1908 | 1908 | $imagesize = getimagesize($src_file); |
| 1909 | 1909 | |
| 1910 | - if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) { |
|
| 1910 | + if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1]) { |
|
| 1911 | 1911 | $actual_aspect = $imagesize[0] / $imagesize[1]; |
| 1912 | 1912 | $desired_aspect = $max_dims[0] / $max_dims[1]; |
| 1913 | 1913 | |
| 1914 | - if ( $actual_aspect >= $desired_aspect ) { |
|
| 1914 | + if ($actual_aspect >= $desired_aspect) { |
|
| 1915 | 1915 | $height = $actual_aspect * $max_dims[0]; |
| 1916 | 1916 | $constraint = "width='{$max_dims[0]}' "; |
| 1917 | 1917 | $post->iconsize = array($max_dims[0], $height); |
@@ -1932,7 +1932,7 @@ discard block |
||
| 1932 | 1932 | |
| 1933 | 1933 | $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>"; |
| 1934 | 1934 | |
| 1935 | - return apply_filters( 'attachment_icon', $icon, $post->ID ); |
|
| 1935 | + return apply_filters('attachment_icon', $icon, $post->ID); |
|
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | /** |
@@ -1948,12 +1948,12 @@ discard block |
||
| 1948 | 1948 | * @return false|string |
| 1949 | 1949 | */ |
| 1950 | 1950 | function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { |
| 1951 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); |
|
| 1951 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_get_attachment_image()'); |
|
| 1952 | 1952 | $id = (int) $id; |
| 1953 | - if ( !$post = get_post($id) ) |
|
| 1953 | + if ( ! $post = get_post($id)) |
|
| 1954 | 1954 | return false; |
| 1955 | 1955 | |
| 1956 | - if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
| 1956 | + if ($innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
| 1957 | 1957 | return $innerHTML; |
| 1958 | 1958 | |
| 1959 | 1959 | $innerHTML = esc_attr($post->post_title); |
@@ -1973,7 +1973,7 @@ discard block |
||
| 1973 | 1973 | * @return object|array |
| 1974 | 1974 | */ |
| 1975 | 1975 | function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') { |
| 1976 | - _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' ); |
|
| 1976 | + _deprecated_function(__FUNCTION__, '2.1', 'get_bookmark()'); |
|
| 1977 | 1977 | return get_bookmark($bookmark_id, $output, $filter); |
| 1978 | 1978 | } |
| 1979 | 1979 | |
@@ -1988,9 +1988,9 @@ discard block |
||
| 1988 | 1988 | * @param array $protocols An array of acceptable protocols. |
| 1989 | 1989 | * @return string The cleaned URL. |
| 1990 | 1990 | */ |
| 1991 | -function sanitize_url( $url, $protocols = null ) { |
|
| 1992 | - _deprecated_function( __FUNCTION__, '2.8', 'esc_url_raw()' ); |
|
| 1993 | - return esc_url_raw( $url, $protocols ); |
|
| 1991 | +function sanitize_url($url, $protocols = null) { |
|
| 1992 | + _deprecated_function(__FUNCTION__, '2.8', 'esc_url_raw()'); |
|
| 1993 | + return esc_url_raw($url, $protocols); |
|
| 1994 | 1994 | } |
| 1995 | 1995 | |
| 1996 | 1996 | /** |
@@ -2009,12 +2009,12 @@ discard block |
||
| 2009 | 2009 | * @param string $context Optional. How the URL will be used. Default is 'display'. |
| 2010 | 2010 | * @return string The cleaned $url after the 'clean_url' filter is applied. |
| 2011 | 2011 | */ |
| 2012 | -function clean_url( $url, $protocols = null, $context = 'display' ) { |
|
| 2013 | - if ( $context == 'db' ) |
|
| 2014 | - _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' ); |
|
| 2012 | +function clean_url($url, $protocols = null, $context = 'display') { |
|
| 2013 | + if ($context == 'db') |
|
| 2014 | + _deprecated_function('clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()'); |
|
| 2015 | 2015 | else |
| 2016 | - _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' ); |
|
| 2017 | - return esc_url( $url, $protocols, $context ); |
|
| 2016 | + _deprecated_function(__FUNCTION__, '3.0', 'esc_url()'); |
|
| 2017 | + return esc_url($url, $protocols, $context); |
|
| 2018 | 2018 | } |
| 2019 | 2019 | |
| 2020 | 2020 | /** |
@@ -2029,9 +2029,9 @@ discard block |
||
| 2029 | 2029 | * @param string $text The text to be escaped. |
| 2030 | 2030 | * @return string Escaped text. |
| 2031 | 2031 | */ |
| 2032 | -function js_escape( $text ) { |
|
| 2033 | - _deprecated_function( __FUNCTION__, '2.8', 'esc_js()' ); |
|
| 2034 | - return esc_js( $text ); |
|
| 2032 | +function js_escape($text) { |
|
| 2033 | + _deprecated_function(__FUNCTION__, '2.8', 'esc_js()'); |
|
| 2034 | + return esc_js($text); |
|
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
@@ -2040,13 +2040,13 @@ discard block |
||
| 2040 | 2040 | * @deprecated 2.8.0 Use esc_html() |
| 2041 | 2041 | * @see esc_html() |
| 2042 | 2042 | */ |
| 2043 | -function wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
|
| 2044 | - _deprecated_function( __FUNCTION__, '2.8', 'esc_html()' ); |
|
| 2045 | - if ( func_num_args() > 1 ) { // Maintain backwards compat for people passing additional args |
|
| 2043 | +function wp_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { |
|
| 2044 | + _deprecated_function(__FUNCTION__, '2.8', 'esc_html()'); |
|
| 2045 | + if (func_num_args() > 1) { // Maintain backwards compat for people passing additional args |
|
| 2046 | 2046 | $args = func_get_args(); |
| 2047 | - return call_user_func_array( '_wp_specialchars', $args ); |
|
| 2047 | + return call_user_func_array('_wp_specialchars', $args); |
|
| 2048 | 2048 | } else { |
| 2049 | - return esc_html( $string ); |
|
| 2049 | + return esc_html($string); |
|
| 2050 | 2050 | } |
| 2051 | 2051 | } |
| 2052 | 2052 | |
@@ -2060,9 +2060,9 @@ discard block |
||
| 2060 | 2060 | * @param string $text |
| 2061 | 2061 | * @return string |
| 2062 | 2062 | */ |
| 2063 | -function attribute_escape( $text ) { |
|
| 2064 | - _deprecated_function( __FUNCTION__, '2.8', 'esc_attr()' ); |
|
| 2065 | - return esc_attr( $text ); |
|
| 2063 | +function attribute_escape($text) { |
|
| 2064 | + _deprecated_function(__FUNCTION__, '2.8', 'esc_attr()'); |
|
| 2065 | + return esc_attr($text); |
|
| 2066 | 2066 | } |
| 2067 | 2067 | |
| 2068 | 2068 | /** |
@@ -2085,10 +2085,10 @@ discard block |
||
| 2085 | 2085 | * @param mixed $params ,... Widget parameters. |
| 2086 | 2086 | */ |
| 2087 | 2087 | function register_sidebar_widget($name, $output_callback, $classname = '') { |
| 2088 | - _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' ); |
|
| 2088 | + _deprecated_function(__FUNCTION__, '2.8', 'wp_register_sidebar_widget()'); |
|
| 2089 | 2089 | // Compat |
| 2090 | - if ( is_array($name) ) { |
|
| 2091 | - if ( count($name) == 3 ) |
|
| 2090 | + if (is_array($name)) { |
|
| 2091 | + if (count($name) == 3) |
|
| 2092 | 2092 | $name = sprintf($name[0], $name[2]); |
| 2093 | 2093 | else |
| 2094 | 2094 | $name = $name[0]; |
@@ -2096,11 +2096,11 @@ discard block |
||
| 2096 | 2096 | |
| 2097 | 2097 | $id = sanitize_title($name); |
| 2098 | 2098 | $options = array(); |
| 2099 | - if ( !empty($classname) && is_string($classname) ) |
|
| 2099 | + if ( ! empty($classname) && is_string($classname)) |
|
| 2100 | 2100 | $options['classname'] = $classname; |
| 2101 | 2101 | $params = array_slice(func_get_args(), 2); |
| 2102 | 2102 | $args = array($id, $name, $output_callback, $options); |
| 2103 | - if ( !empty($params) ) |
|
| 2103 | + if ( ! empty($params)) |
|
| 2104 | 2104 | $args = array_merge($args, $params); |
| 2105 | 2105 | |
| 2106 | 2106 | call_user_func_array('wp_register_sidebar_widget', $args); |
@@ -2116,7 +2116,7 @@ discard block |
||
| 2116 | 2116 | * @param int|string $id Widget ID. |
| 2117 | 2117 | */ |
| 2118 | 2118 | function unregister_sidebar_widget($id) { |
| 2119 | - _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()' ); |
|
| 2119 | + _deprecated_function(__FUNCTION__, '2.8', 'wp_unregister_sidebar_widget()'); |
|
| 2120 | 2120 | return wp_unregister_sidebar_widget($id); |
| 2121 | 2121 | } |
| 2122 | 2122 | |
@@ -2140,10 +2140,10 @@ discard block |
||
| 2140 | 2140 | * @param int $height Widget height. |
| 2141 | 2141 | */ |
| 2142 | 2142 | function register_widget_control($name, $control_callback, $width = '', $height = '') { |
| 2143 | - _deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' ); |
|
| 2143 | + _deprecated_function(__FUNCTION__, '2.8', 'wp_register_widget_control()'); |
|
| 2144 | 2144 | // Compat |
| 2145 | - if ( is_array($name) ) { |
|
| 2146 | - if ( count($name) == 3 ) |
|
| 2145 | + if (is_array($name)) { |
|
| 2146 | + if (count($name) == 3) |
|
| 2147 | 2147 | $name = sprintf($name[0], $name[2]); |
| 2148 | 2148 | else |
| 2149 | 2149 | $name = $name[0]; |
@@ -2151,13 +2151,13 @@ discard block |
||
| 2151 | 2151 | |
| 2152 | 2152 | $id = sanitize_title($name); |
| 2153 | 2153 | $options = array(); |
| 2154 | - if ( !empty($width) ) |
|
| 2154 | + if ( ! empty($width)) |
|
| 2155 | 2155 | $options['width'] = $width; |
| 2156 | - if ( !empty($height) ) |
|
| 2156 | + if ( ! empty($height)) |
|
| 2157 | 2157 | $options['height'] = $height; |
| 2158 | 2158 | $params = array_slice(func_get_args(), 4); |
| 2159 | 2159 | $args = array($id, $name, $control_callback, $options); |
| 2160 | - if ( !empty($params) ) |
|
| 2160 | + if ( ! empty($params)) |
|
| 2161 | 2161 | $args = array_merge($args, $params); |
| 2162 | 2162 | |
| 2163 | 2163 | call_user_func_array('wp_register_widget_control', $args); |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | * @param int|string $id Widget ID. |
| 2174 | 2174 | */ |
| 2175 | 2175 | function unregister_widget_control($id) { |
| 2176 | - _deprecated_function( __FUNCTION__, '2.8', 'wp_unregister_widget_control()' ); |
|
| 2176 | + _deprecated_function(__FUNCTION__, '2.8', 'wp_unregister_widget_control()'); |
|
| 2177 | 2177 | return wp_unregister_widget_control($id); |
| 2178 | 2178 | } |
| 2179 | 2179 | |
@@ -2189,32 +2189,32 @@ discard block |
||
| 2189 | 2189 | * @param mixed $meta_value Metadata value. |
| 2190 | 2190 | * @return bool True deletion completed and false if user_id is not a number. |
| 2191 | 2191 | */ |
| 2192 | -function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { |
|
| 2193 | - _deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' ); |
|
| 2192 | +function delete_usermeta($user_id, $meta_key, $meta_value = '') { |
|
| 2193 | + _deprecated_function(__FUNCTION__, '3.0', 'delete_user_meta()'); |
|
| 2194 | 2194 | global $wpdb; |
| 2195 | - if ( !is_numeric( $user_id ) ) |
|
| 2195 | + if ( ! is_numeric($user_id)) |
|
| 2196 | 2196 | return false; |
| 2197 | 2197 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2198 | 2198 | |
| 2199 | - if ( is_array($meta_value) || is_object($meta_value) ) |
|
| 2199 | + if (is_array($meta_value) || is_object($meta_value)) |
|
| 2200 | 2200 | $meta_value = serialize($meta_value); |
| 2201 | - $meta_value = trim( $meta_value ); |
|
| 2201 | + $meta_value = trim($meta_value); |
|
| 2202 | 2202 | |
| 2203 | - $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2203 | + $cur = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
| 2204 | 2204 | |
| 2205 | - if ( $cur && $cur->umeta_id ) |
|
| 2206 | - do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2205 | + if ($cur && $cur->umeta_id) |
|
| 2206 | + do_action('delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
| 2207 | 2207 | |
| 2208 | - if ( ! empty($meta_value) ) |
|
| 2209 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
| 2208 | + if ( ! empty($meta_value)) |
|
| 2209 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value)); |
|
| 2210 | 2210 | else |
| 2211 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2211 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
| 2212 | 2212 | |
| 2213 | - clean_user_cache( $user_id ); |
|
| 2214 | - wp_cache_delete( $user_id, 'user_meta' ); |
|
| 2213 | + clean_user_cache($user_id); |
|
| 2214 | + wp_cache_delete($user_id, 'user_meta'); |
|
| 2215 | 2215 | |
| 2216 | - if ( $cur && $cur->umeta_id ) |
|
| 2217 | - do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2216 | + if ($cur && $cur->umeta_id) |
|
| 2217 | + do_action('deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
| 2218 | 2218 | |
| 2219 | 2219 | return true; |
| 2220 | 2220 | } |
@@ -2235,28 +2235,28 @@ discard block |
||
| 2235 | 2235 | * @param string $meta_key Optional. Metadata key. |
| 2236 | 2236 | * @return mixed |
| 2237 | 2237 | */ |
| 2238 | -function get_usermeta( $user_id, $meta_key = '' ) { |
|
| 2239 | - _deprecated_function( __FUNCTION__, '3.0', 'get_user_meta()' ); |
|
| 2238 | +function get_usermeta($user_id, $meta_key = '') { |
|
| 2239 | + _deprecated_function(__FUNCTION__, '3.0', 'get_user_meta()'); |
|
| 2240 | 2240 | global $wpdb; |
| 2241 | 2241 | $user_id = (int) $user_id; |
| 2242 | 2242 | |
| 2243 | - if ( !$user_id ) |
|
| 2243 | + if ( ! $user_id) |
|
| 2244 | 2244 | return false; |
| 2245 | 2245 | |
| 2246 | - if ( !empty($meta_key) ) { |
|
| 2246 | + if ( ! empty($meta_key)) { |
|
| 2247 | 2247 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2248 | 2248 | $user = wp_cache_get($user_id, 'users'); |
| 2249 | 2249 | // Check the cached user object |
| 2250 | - if ( false !== $user && isset($user->$meta_key) ) |
|
| 2250 | + if (false !== $user && isset($user->$meta_key)) |
|
| 2251 | 2251 | $metas = array($user->$meta_key); |
| 2252 | 2252 | else |
| 2253 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2253 | + $metas = $wpdb->get_col($wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
| 2254 | 2254 | } else { |
| 2255 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); |
|
| 2255 | + $metas = $wpdb->get_col($wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id)); |
|
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | - if ( empty($metas) ) { |
|
| 2259 | - if ( empty($meta_key) ) |
|
| 2258 | + if (empty($metas)) { |
|
| 2259 | + if (empty($meta_key)) |
|
| 2260 | 2260 | return array(); |
| 2261 | 2261 | else |
| 2262 | 2262 | return ''; |
@@ -2264,7 +2264,7 @@ discard block |
||
| 2264 | 2264 | |
| 2265 | 2265 | $metas = array_map('maybe_unserialize', $metas); |
| 2266 | 2266 | |
| 2267 | - if ( count($metas) == 1 ) |
|
| 2267 | + if (count($metas) == 1) |
|
| 2268 | 2268 | return $metas[0]; |
| 2269 | 2269 | else |
| 2270 | 2270 | return $metas; |
@@ -2288,15 +2288,15 @@ discard block |
||
| 2288 | 2288 | * @param mixed $meta_value Metadata value. |
| 2289 | 2289 | * @return bool True on successful update, false on failure. |
| 2290 | 2290 | */ |
| 2291 | -function update_usermeta( $user_id, $meta_key, $meta_value ) { |
|
| 2292 | - _deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' ); |
|
| 2291 | +function update_usermeta($user_id, $meta_key, $meta_value) { |
|
| 2292 | + _deprecated_function(__FUNCTION__, '3.0', 'update_user_meta()'); |
|
| 2293 | 2293 | global $wpdb; |
| 2294 | - if ( !is_numeric( $user_id ) ) |
|
| 2294 | + if ( ! is_numeric($user_id)) |
|
| 2295 | 2295 | return false; |
| 2296 | 2296 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2297 | 2297 | |
| 2298 | 2298 | /** @todo Might need fix because usermeta data is assumed to be already escaped */ |
| 2299 | - if ( is_string($meta_value) ) |
|
| 2299 | + if (is_string($meta_value)) |
|
| 2300 | 2300 | $meta_value = stripslashes($meta_value); |
| 2301 | 2301 | $meta_value = maybe_serialize($meta_value); |
| 2302 | 2302 | |
@@ -2304,25 +2304,25 @@ discard block |
||
| 2304 | 2304 | return delete_usermeta($user_id, $meta_key); |
| 2305 | 2305 | } |
| 2306 | 2306 | |
| 2307 | - $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2307 | + $cur = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key)); |
|
| 2308 | 2308 | |
| 2309 | - if ( $cur ) |
|
| 2310 | - do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2309 | + if ($cur) |
|
| 2310 | + do_action('update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
| 2311 | 2311 | |
| 2312 | - if ( !$cur ) |
|
| 2313 | - $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
| 2314 | - elseif ( $cur->meta_value != $meta_value ) |
|
| 2315 | - $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
| 2312 | + if ( ! $cur) |
|
| 2313 | + $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value')); |
|
| 2314 | + elseif ($cur->meta_value != $meta_value) |
|
| 2315 | + $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key')); |
|
| 2316 | 2316 | else |
| 2317 | 2317 | return false; |
| 2318 | 2318 | |
| 2319 | - clean_user_cache( $user_id ); |
|
| 2320 | - wp_cache_delete( $user_id, 'user_meta' ); |
|
| 2319 | + clean_user_cache($user_id); |
|
| 2320 | + wp_cache_delete($user_id, 'user_meta'); |
|
| 2321 | 2321 | |
| 2322 | - if ( !$cur ) |
|
| 2323 | - do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
| 2322 | + if ( ! $cur) |
|
| 2323 | + do_action('added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value); |
|
| 2324 | 2324 | else |
| 2325 | - do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2325 | + do_action('updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value); |
|
| 2326 | 2326 | |
| 2327 | 2327 | return true; |
| 2328 | 2328 | } |
@@ -2343,14 +2343,14 @@ discard block |
||
| 2343 | 2343 | * @param int $id Blog ID. |
| 2344 | 2344 | * @return array List of users that are part of that Blog ID |
| 2345 | 2345 | */ |
| 2346 | -function get_users_of_blog( $id = '' ) { |
|
| 2347 | - _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
|
| 2346 | +function get_users_of_blog($id = '') { |
|
| 2347 | + _deprecated_function(__FUNCTION__, '3.1', 'get_users()'); |
|
| 2348 | 2348 | |
| 2349 | 2349 | global $wpdb, $blog_id; |
| 2350 | - if ( empty($id) ) |
|
| 2350 | + if (empty($id)) |
|
| 2351 | 2351 | $id = (int) $blog_id; |
| 2352 | 2352 | $blog_prefix = $wpdb->get_blog_prefix($id); |
| 2353 | - $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); |
|
| 2353 | + $users = $wpdb->get_results("SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id"); |
|
| 2354 | 2354 | return $users; |
| 2355 | 2355 | } |
| 2356 | 2356 | |
@@ -2363,13 +2363,13 @@ discard block |
||
| 2363 | 2363 | * |
| 2364 | 2364 | * @param bool $add Optional, default is true. Add or remove links. Defaults to true. |
| 2365 | 2365 | */ |
| 2366 | -function automatic_feed_links( $add = true ) { |
|
| 2367 | - _deprecated_function( __FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )" ); |
|
| 2366 | +function automatic_feed_links($add = true) { |
|
| 2367 | + _deprecated_function(__FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )"); |
|
| 2368 | 2368 | |
| 2369 | - if ( $add ) |
|
| 2370 | - add_theme_support( 'automatic-feed-links' ); |
|
| 2369 | + if ($add) |
|
| 2370 | + add_theme_support('automatic-feed-links'); |
|
| 2371 | 2371 | else |
| 2372 | - remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ |
|
| 2372 | + remove_action('wp_head', 'feed_links_extra', 3); // Just do this yourself in 3.0+ |
|
| 2373 | 2373 | } |
| 2374 | 2374 | |
| 2375 | 2375 | /** |
@@ -2379,13 +2379,13 @@ discard block |
||
| 2379 | 2379 | * @deprecated 3.0.0 Use get_the_author_meta() |
| 2380 | 2380 | * @see get_the_author_meta() |
| 2381 | 2381 | */ |
| 2382 | -function get_profile( $field, $user = false ) { |
|
| 2383 | - _deprecated_function( __FUNCTION__, '3.0', 'get_the_author_meta()' ); |
|
| 2384 | - if ( $user ) { |
|
| 2385 | - $user = get_user_by( 'login', $user ); |
|
| 2382 | +function get_profile($field, $user = false) { |
|
| 2383 | + _deprecated_function(__FUNCTION__, '3.0', 'get_the_author_meta()'); |
|
| 2384 | + if ($user) { |
|
| 2385 | + $user = get_user_by('login', $user); |
|
| 2386 | 2386 | $user = $user->ID; |
| 2387 | 2387 | } |
| 2388 | - return get_the_author_meta( $field, $user ); |
|
| 2388 | + return get_the_author_meta($field, $user); |
|
| 2389 | 2389 | } |
| 2390 | 2390 | |
| 2391 | 2391 | /** |
@@ -2395,9 +2395,9 @@ discard block |
||
| 2395 | 2395 | * @deprecated 3.0.0 Use count_user_posts() |
| 2396 | 2396 | * @see count_user_posts() |
| 2397 | 2397 | */ |
| 2398 | -function get_usernumposts( $userid ) { |
|
| 2399 | - _deprecated_function( __FUNCTION__, '3.0', 'count_user_posts()' ); |
|
| 2400 | - return count_user_posts( $userid ); |
|
| 2398 | +function get_usernumposts($userid) { |
|
| 2399 | + _deprecated_function(__FUNCTION__, '3.0', 'count_user_posts()'); |
|
| 2400 | + return count_user_posts($userid); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /** |
@@ -2411,7 +2411,7 @@ discard block |
||
| 2411 | 2411 | * @return string An HTML entity |
| 2412 | 2412 | */ |
| 2413 | 2413 | function funky_javascript_callback($matches) { |
| 2414 | - return "&#".base_convert($matches[1],16,10).";"; |
|
| 2414 | + return "&#".base_convert($matches[1], 16, 10).";"; |
|
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | /** |
@@ -2429,12 +2429,12 @@ discard block |
||
| 2429 | 2429 | * @return string Fixed text. |
| 2430 | 2430 | */ |
| 2431 | 2431 | function funky_javascript_fix($text) { |
| 2432 | - _deprecated_function( __FUNCTION__, '3.0' ); |
|
| 2432 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
| 2433 | 2433 | // Fixes for browsers' JavaScript bugs. |
| 2434 | 2434 | global $is_macIE, $is_winIE; |
| 2435 | 2435 | |
| 2436 | - if ( $is_winIE || $is_macIE ) |
|
| 2437 | - $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
| 2436 | + if ($is_winIE || $is_macIE) |
|
| 2437 | + $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
| 2438 | 2438 | "funky_javascript_callback", |
| 2439 | 2439 | $text); |
| 2440 | 2440 | |
@@ -2451,9 +2451,9 @@ discard block |
||
| 2451 | 2451 | * @param string $taxonomy Name of taxonomy object |
| 2452 | 2452 | * @return bool Whether the taxonomy exists. |
| 2453 | 2453 | */ |
| 2454 | -function is_taxonomy( $taxonomy ) { |
|
| 2455 | - _deprecated_function( __FUNCTION__, '3.0', 'taxonomy_exists()' ); |
|
| 2456 | - return taxonomy_exists( $taxonomy ); |
|
| 2454 | +function is_taxonomy($taxonomy) { |
|
| 2455 | + _deprecated_function(__FUNCTION__, '3.0', 'taxonomy_exists()'); |
|
| 2456 | + return taxonomy_exists($taxonomy); |
|
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | /** |
@@ -2468,9 +2468,9 @@ discard block |
||
| 2468 | 2468 | * @param int $parent ID of parent term under which to confine the exists search. |
| 2469 | 2469 | * @return mixed Get the term id or Term Object, if exists. |
| 2470 | 2470 | */ |
| 2471 | -function is_term( $term, $taxonomy = '', $parent = 0 ) { |
|
| 2472 | - _deprecated_function( __FUNCTION__, '3.0', 'term_exists()' ); |
|
| 2473 | - return term_exists( $term, $taxonomy, $parent ); |
|
| 2471 | +function is_term($term, $taxonomy = '', $parent = 0) { |
|
| 2472 | + _deprecated_function(__FUNCTION__, '3.0', 'term_exists()'); |
|
| 2473 | + return term_exists($term, $taxonomy, $parent); |
|
| 2474 | 2474 | } |
| 2475 | 2475 | |
| 2476 | 2476 | /** |
@@ -2486,11 +2486,11 @@ discard block |
||
| 2486 | 2486 | * @return bool |
| 2487 | 2487 | */ |
| 2488 | 2488 | function is_plugin_page() { |
| 2489 | - _deprecated_function( __FUNCTION__, '3.1' ); |
|
| 2489 | + _deprecated_function(__FUNCTION__, '3.1'); |
|
| 2490 | 2490 | |
| 2491 | 2491 | global $plugin_page; |
| 2492 | 2492 | |
| 2493 | - if ( isset($plugin_page) ) |
|
| 2493 | + if (isset($plugin_page)) |
|
| 2494 | 2494 | return true; |
| 2495 | 2495 | |
| 2496 | 2496 | return false; |
@@ -2509,7 +2509,7 @@ discard block |
||
| 2509 | 2509 | * @return bool Always return True |
| 2510 | 2510 | */ |
| 2511 | 2511 | function update_category_cache() { |
| 2512 | - _deprecated_function( __FUNCTION__, '3.1' ); |
|
| 2512 | + _deprecated_function(__FUNCTION__, '3.1'); |
|
| 2513 | 2513 | |
| 2514 | 2514 | return true; |
| 2515 | 2515 | } |
@@ -2523,7 +2523,7 @@ discard block |
||
| 2523 | 2523 | * @return bool |
| 2524 | 2524 | */ |
| 2525 | 2525 | function wp_timezone_supported() { |
| 2526 | - _deprecated_function( __FUNCTION__, '3.2' ); |
|
| 2526 | + _deprecated_function(__FUNCTION__, '3.2'); |
|
| 2527 | 2527 | |
| 2528 | 2528 | return true; |
| 2529 | 2529 | } |
@@ -2542,9 +2542,9 @@ discard block |
||
| 2542 | 2542 | * @param int $tab_index Optional, not used |
| 2543 | 2543 | */ |
| 2544 | 2544 | function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { |
| 2545 | - _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); |
|
| 2545 | + _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()'); |
|
| 2546 | 2546 | |
| 2547 | - wp_editor( $content, $id, array( 'media_buttons' => $media_buttons ) ); |
|
| 2547 | + wp_editor($content, $id, array('media_buttons' => $media_buttons)); |
|
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
@@ -2557,20 +2557,20 @@ discard block |
||
| 2557 | 2557 | * @return array of arrays. The array is indexed by user_id, containing $metavalues object arrays. |
| 2558 | 2558 | */ |
| 2559 | 2559 | function get_user_metavalues($ids) { |
| 2560 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2560 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2561 | 2561 | |
| 2562 | 2562 | $objects = array(); |
| 2563 | 2563 | |
| 2564 | 2564 | $ids = array_map('intval', $ids); |
| 2565 | - foreach ( $ids as $id ) |
|
| 2565 | + foreach ($ids as $id) |
|
| 2566 | 2566 | $objects[$id] = array(); |
| 2567 | 2567 | |
| 2568 | 2568 | $metas = update_meta_cache('user', $ids); |
| 2569 | 2569 | |
| 2570 | - foreach ( $metas as $id => $meta ) { |
|
| 2571 | - foreach ( $meta as $key => $metavalues ) { |
|
| 2572 | - foreach ( $metavalues as $value ) { |
|
| 2573 | - $objects[$id][] = (object)array( 'user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); |
|
| 2570 | + foreach ($metas as $id => $meta) { |
|
| 2571 | + foreach ($meta as $key => $metavalues) { |
|
| 2572 | + foreach ($metavalues as $value) { |
|
| 2573 | + $objects[$id][] = (object) array('user_id' => $id, 'meta_key' => $key, 'meta_value' => $value); |
|
| 2574 | 2574 | } |
| 2575 | 2575 | } |
| 2576 | 2576 | } |
@@ -2591,23 +2591,23 @@ discard block |
||
| 2591 | 2591 | * @return object|array The now sanitized User Object or Array (will be the same type as $user) |
| 2592 | 2592 | */ |
| 2593 | 2593 | function sanitize_user_object($user, $context = 'display') { |
| 2594 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2594 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2595 | 2595 | |
| 2596 | - if ( is_object($user) ) { |
|
| 2597 | - if ( !isset($user->ID) ) |
|
| 2596 | + if (is_object($user)) { |
|
| 2597 | + if ( ! isset($user->ID)) |
|
| 2598 | 2598 | $user->ID = 0; |
| 2599 | - if ( ! ( $user instanceof WP_User ) ) { |
|
| 2599 | + if ( ! ($user instanceof WP_User)) { |
|
| 2600 | 2600 | $vars = get_object_vars($user); |
| 2601 | - foreach ( array_keys($vars) as $field ) { |
|
| 2602 | - if ( is_string($user->$field) || is_numeric($user->$field) ) |
|
| 2601 | + foreach (array_keys($vars) as $field) { |
|
| 2602 | + if (is_string($user->$field) || is_numeric($user->$field)) |
|
| 2603 | 2603 | $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
| 2604 | 2604 | } |
| 2605 | 2605 | } |
| 2606 | 2606 | $user->filter = $context; |
| 2607 | 2607 | } else { |
| 2608 | - if ( !isset($user['ID']) ) |
|
| 2608 | + if ( ! isset($user['ID'])) |
|
| 2609 | 2609 | $user['ID'] = 0; |
| 2610 | - foreach ( array_keys($user) as $field ) |
|
| 2610 | + foreach (array_keys($user) as $field) |
|
| 2611 | 2611 | $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
| 2612 | 2612 | $user['filter'] = $context; |
| 2613 | 2613 | } |
@@ -2630,17 +2630,17 @@ discard block |
||
| 2630 | 2630 | * @return string |
| 2631 | 2631 | */ |
| 2632 | 2632 | function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { |
| 2633 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2633 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2634 | 2634 | |
| 2635 | 2635 | $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); |
| 2636 | 2636 | // If there is no post stop. |
| 2637 | - if ( empty($posts) ) |
|
| 2637 | + if (empty($posts)) |
|
| 2638 | 2638 | return; |
| 2639 | 2639 | |
| 2640 | 2640 | // Even though we limited get_posts to return only 1 item it still returns an array of objects. |
| 2641 | 2641 | $post = $posts[0]; |
| 2642 | 2642 | |
| 2643 | - if ( empty($post->post_title) ) |
|
| 2643 | + if (empty($post->post_title)) |
|
| 2644 | 2644 | $post->post_title = $start ? __('First Post') : __('Last Post'); |
| 2645 | 2645 | |
| 2646 | 2646 | $date = mysql2date(get_option('date_format'), $post->post_date); |
@@ -2651,10 +2651,10 @@ discard block |
||
| 2651 | 2651 | |
| 2652 | 2652 | $link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; |
| 2653 | 2653 | $link .= esc_attr($title); |
| 2654 | - $link .= "' href='" . get_permalink($post) . "' />\n"; |
|
| 2654 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
| 2655 | 2655 | |
| 2656 | 2656 | $boundary = $start ? 'start' : 'end'; |
| 2657 | - return apply_filters( "{$boundary}_post_rel_link", $link ); |
|
| 2657 | + return apply_filters("{$boundary}_post_rel_link", $link); |
|
| 2658 | 2658 | } |
| 2659 | 2659 | |
| 2660 | 2660 | /** |
@@ -2668,7 +2668,7 @@ discard block |
||
| 2668 | 2668 | * @param string $excluded_categories Optional. Excluded categories IDs. |
| 2669 | 2669 | */ |
| 2670 | 2670 | function start_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') { |
| 2671 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2671 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2672 | 2672 | |
| 2673 | 2673 | echo get_boundary_post_rel_link($title, $in_same_cat, $excluded_categories, true); |
| 2674 | 2674 | } |
@@ -2682,10 +2682,10 @@ discard block |
||
| 2682 | 2682 | * @return string |
| 2683 | 2683 | */ |
| 2684 | 2684 | function get_index_rel_link() { |
| 2685 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2685 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2686 | 2686 | |
| 2687 | - $link = "<link rel='index' title='" . esc_attr( get_bloginfo( 'name', 'display' ) ) . "' href='" . esc_url( user_trailingslashit( get_bloginfo( 'url', 'display' ) ) ) . "' />\n"; |
|
| 2688 | - return apply_filters( "index_rel_link", $link ); |
|
| 2687 | + $link = "<link rel='index' title='".esc_attr(get_bloginfo('name', 'display'))."' href='".esc_url(user_trailingslashit(get_bloginfo('url', 'display')))."' />\n"; |
|
| 2688 | + return apply_filters("index_rel_link", $link); |
|
| 2689 | 2689 | } |
| 2690 | 2690 | |
| 2691 | 2691 | /** |
@@ -2695,7 +2695,7 @@ discard block |
||
| 2695 | 2695 | * @deprecated 3.3.0 |
| 2696 | 2696 | */ |
| 2697 | 2697 | function index_rel_link() { |
| 2698 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2698 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2699 | 2699 | |
| 2700 | 2700 | echo get_index_rel_link(); |
| 2701 | 2701 | } |
@@ -2710,12 +2710,12 @@ discard block |
||
| 2710 | 2710 | * @return string |
| 2711 | 2711 | */ |
| 2712 | 2712 | function get_parent_post_rel_link($title = '%title') { |
| 2713 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2713 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2714 | 2714 | |
| 2715 | - if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) |
|
| 2715 | + if ( ! empty($GLOBALS['post']) && ! empty($GLOBALS['post']->post_parent)) |
|
| 2716 | 2716 | $post = get_post($GLOBALS['post']->post_parent); |
| 2717 | 2717 | |
| 2718 | - if ( empty($post) ) |
|
| 2718 | + if (empty($post)) |
|
| 2719 | 2719 | return; |
| 2720 | 2720 | |
| 2721 | 2721 | $date = mysql2date(get_option('date_format'), $post->post_date); |
@@ -2725,10 +2725,10 @@ discard block |
||
| 2725 | 2725 | $title = apply_filters('the_title', $title, $post->ID); |
| 2726 | 2726 | |
| 2727 | 2727 | $link = "<link rel='up' title='"; |
| 2728 | - $link .= esc_attr( $title ); |
|
| 2729 | - $link .= "' href='" . get_permalink($post) . "' />\n"; |
|
| 2728 | + $link .= esc_attr($title); |
|
| 2729 | + $link .= "' href='".get_permalink($post)."' />\n"; |
|
| 2730 | 2730 | |
| 2731 | - return apply_filters( "parent_post_rel_link", $link ); |
|
| 2731 | + return apply_filters("parent_post_rel_link", $link); |
|
| 2732 | 2732 | } |
| 2733 | 2733 | |
| 2734 | 2734 | /** |
@@ -2738,7 +2738,7 @@ discard block |
||
| 2738 | 2738 | * @deprecated 3.3.0 |
| 2739 | 2739 | */ |
| 2740 | 2740 | function parent_post_rel_link($title = '%title') { |
| 2741 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2741 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2742 | 2742 | |
| 2743 | 2743 | echo get_parent_post_rel_link($title); |
| 2744 | 2744 | } |
@@ -2749,18 +2749,18 @@ discard block |
||
| 2749 | 2749 | * @since 3.2.0 |
| 2750 | 2750 | * @deprecated 3.3.0 |
| 2751 | 2751 | */ |
| 2752 | -function wp_admin_bar_dashboard_view_site_menu( $wp_admin_bar ) { |
|
| 2753 | - _deprecated_function( __FUNCTION__, '3.3' ); |
|
| 2752 | +function wp_admin_bar_dashboard_view_site_menu($wp_admin_bar) { |
|
| 2753 | + _deprecated_function(__FUNCTION__, '3.3'); |
|
| 2754 | 2754 | |
| 2755 | 2755 | $user_id = get_current_user_id(); |
| 2756 | 2756 | |
| 2757 | - if ( 0 != $user_id ) { |
|
| 2758 | - if ( is_admin() ) |
|
| 2759 | - $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
| 2760 | - elseif ( is_multisite() ) |
|
| 2761 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
| 2757 | + if (0 != $user_id) { |
|
| 2758 | + if (is_admin()) |
|
| 2759 | + $wp_admin_bar->add_menu(array('id' => 'view-site', 'title' => __('Visit Site'), 'href' => home_url())); |
|
| 2760 | + elseif (is_multisite()) |
|
| 2761 | + $wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => get_dashboard_url($user_id))); |
|
| 2762 | 2762 | else |
| 2763 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
| 2763 | + $wp_admin_bar->add_menu(array('id' => 'dashboard', 'title' => __('Dashboard'), 'href' => admin_url())); |
|
| 2764 | 2764 | } |
| 2765 | 2765 | } |
| 2766 | 2766 | |
@@ -2774,10 +2774,10 @@ discard block |
||
| 2774 | 2774 | * @param int $blog_id Blog ID |
| 2775 | 2775 | * @return bool True if the current users belong to $blog_id, false if not. |
| 2776 | 2776 | */ |
| 2777 | -function is_blog_user( $blog_id = 0 ) { |
|
| 2778 | - _deprecated_function( __FUNCTION__, '3.3', 'is_user_member_of_blog()' ); |
|
| 2777 | +function is_blog_user($blog_id = 0) { |
|
| 2778 | + _deprecated_function(__FUNCTION__, '3.3', 'is_user_member_of_blog()'); |
|
| 2779 | 2779 | |
| 2780 | - return is_user_member_of_blog( get_current_user_id(), $blog_id ); |
|
| 2780 | + return is_user_member_of_blog(get_current_user_id(), $blog_id); |
|
| 2781 | 2781 | } |
| 2782 | 2782 | |
| 2783 | 2783 | /** |
@@ -2789,8 +2789,8 @@ discard block |
||
| 2789 | 2789 | * |
| 2790 | 2790 | * @link http://www.php.net/manual/en/function.error-log.php |
| 2791 | 2791 | */ |
| 2792 | -function debug_fopen( $filename, $mode ) { |
|
| 2793 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
| 2792 | +function debug_fopen($filename, $mode) { |
|
| 2793 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
| 2794 | 2794 | return false; |
| 2795 | 2795 | } |
| 2796 | 2796 | |
@@ -2803,10 +2803,10 @@ discard block |
||
| 2803 | 2803 | * |
| 2804 | 2804 | * @link http://www.php.net/manual/en/function.error-log.php |
| 2805 | 2805 | */ |
| 2806 | -function debug_fwrite( $fp, $string ) { |
|
| 2807 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
| 2808 | - if ( ! empty( $GLOBALS['debug'] ) ) |
|
| 2809 | - error_log( $string ); |
|
| 2806 | +function debug_fwrite($fp, $string) { |
|
| 2807 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
| 2808 | + if ( ! empty($GLOBALS['debug'])) |
|
| 2809 | + error_log($string); |
|
| 2810 | 2810 | } |
| 2811 | 2811 | |
| 2812 | 2812 | /** |
@@ -2818,8 +2818,8 @@ discard block |
||
| 2818 | 2818 | * |
| 2819 | 2819 | * @link http://www.php.net/manual/en/function.error-log.php |
| 2820 | 2820 | */ |
| 2821 | -function debug_fclose( $fp ) { |
|
| 2822 | - _deprecated_function( __FUNCTION__, 'error_log()' ); |
|
| 2821 | +function debug_fclose($fp) { |
|
| 2822 | + _deprecated_function(__FUNCTION__, 'error_log()'); |
|
| 2823 | 2823 | } |
| 2824 | 2824 | |
| 2825 | 2825 | /** |
@@ -2836,21 +2836,21 @@ discard block |
||
| 2836 | 2836 | * @return array Theme list with theme data. |
| 2837 | 2837 | */ |
| 2838 | 2838 | function get_themes() { |
| 2839 | - _deprecated_function( __FUNCTION__, '3.4', 'wp_get_themes()' ); |
|
| 2839 | + _deprecated_function(__FUNCTION__, '3.4', 'wp_get_themes()'); |
|
| 2840 | 2840 | |
| 2841 | 2841 | global $wp_themes; |
| 2842 | - if ( isset( $wp_themes ) ) |
|
| 2842 | + if (isset($wp_themes)) |
|
| 2843 | 2843 | return $wp_themes; |
| 2844 | 2844 | |
| 2845 | 2845 | $themes = wp_get_themes(); |
| 2846 | 2846 | $wp_themes = array(); |
| 2847 | 2847 | |
| 2848 | - foreach ( $themes as $theme ) { |
|
| 2848 | + foreach ($themes as $theme) { |
|
| 2849 | 2849 | $name = $theme->get('Name'); |
| 2850 | - if ( isset( $wp_themes[ $name ] ) ) |
|
| 2851 | - $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
| 2850 | + if (isset($wp_themes[$name])) |
|
| 2851 | + $wp_themes[$name.'/'.$theme->get_stylesheet()] = $theme; |
|
| 2852 | 2852 | else |
| 2853 | - $wp_themes[ $name ] = $theme; |
|
| 2853 | + $wp_themes[$name] = $theme; |
|
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | 2856 | return $wp_themes; |
@@ -2866,12 +2866,12 @@ discard block |
||
| 2866 | 2866 | * @param string $theme Theme name. |
| 2867 | 2867 | * @return array|null Null, if theme name does not exist. Theme data, if exists. |
| 2868 | 2868 | */ |
| 2869 | -function get_theme( $theme ) { |
|
| 2870 | - _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme( $stylesheet )' ); |
|
| 2869 | +function get_theme($theme) { |
|
| 2870 | + _deprecated_function(__FUNCTION__, '3.4', 'wp_get_theme( $stylesheet )'); |
|
| 2871 | 2871 | |
| 2872 | 2872 | $themes = get_themes(); |
| 2873 | - if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) |
|
| 2874 | - return $themes[ $theme ]; |
|
| 2873 | + if (is_array($themes) && array_key_exists($theme, $themes)) |
|
| 2874 | + return $themes[$theme]; |
|
| 2875 | 2875 | return null; |
| 2876 | 2876 | } |
| 2877 | 2877 | |
@@ -2885,9 +2885,9 @@ discard block |
||
| 2885 | 2885 | * @return string |
| 2886 | 2886 | */ |
| 2887 | 2887 | function get_current_theme() { |
| 2888 | - _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); |
|
| 2888 | + _deprecated_function(__FUNCTION__, '3.4', 'wp_get_theme()'); |
|
| 2889 | 2889 | |
| 2890 | - if ( $theme = get_option( 'current_theme' ) ) |
|
| 2890 | + if ($theme = get_option('current_theme')) |
|
| 2891 | 2891 | return $theme; |
| 2892 | 2892 | |
| 2893 | 2893 | return wp_get_theme()->get('Name'); |
@@ -2906,10 +2906,10 @@ discard block |
||
| 2906 | 2906 | * @return string The pre block without paragraph/line-break conversion. |
| 2907 | 2907 | */ |
| 2908 | 2908 | function clean_pre($matches) { |
| 2909 | - _deprecated_function( __FUNCTION__, '3.4' ); |
|
| 2909 | + _deprecated_function(__FUNCTION__, '3.4'); |
|
| 2910 | 2910 | |
| 2911 | - if ( is_array($matches) ) |
|
| 2912 | - $text = $matches[1] . $matches[2] . "</pre>"; |
|
| 2911 | + if (is_array($matches)) |
|
| 2912 | + $text = $matches[1].$matches[2]."</pre>"; |
|
| 2913 | 2913 | else |
| 2914 | 2914 | $text = $matches; |
| 2915 | 2915 | |
@@ -2932,15 +2932,15 @@ discard block |
||
| 2932 | 2932 | * @param callback $admin_head_callback Call on custom header administration screen. |
| 2933 | 2933 | * @param callback $admin_preview_callback Output a custom header image div on the custom header administration screen. Optional. |
| 2934 | 2934 | */ |
| 2935 | -function add_custom_image_header( $wp_head_callback, $admin_head_callback, $admin_preview_callback = '' ) { |
|
| 2936 | - _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-header\', $args )' ); |
|
| 2935 | +function add_custom_image_header($wp_head_callback, $admin_head_callback, $admin_preview_callback = '') { |
|
| 2936 | + _deprecated_function(__FUNCTION__, '3.4', 'add_theme_support( \'custom-header\', $args )'); |
|
| 2937 | 2937 | $args = array( |
| 2938 | 2938 | 'wp-head-callback' => $wp_head_callback, |
| 2939 | 2939 | 'admin-head-callback' => $admin_head_callback, |
| 2940 | 2940 | ); |
| 2941 | - if ( $admin_preview_callback ) |
|
| 2941 | + if ($admin_preview_callback) |
|
| 2942 | 2942 | $args['admin-preview-callback'] = $admin_preview_callback; |
| 2943 | - return add_theme_support( 'custom-header', $args ); |
|
| 2943 | + return add_theme_support('custom-header', $args); |
|
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | /** |
@@ -2953,8 +2953,8 @@ discard block |
||
| 2953 | 2953 | * @return null|bool Whether support was removed. |
| 2954 | 2954 | */ |
| 2955 | 2955 | function remove_custom_image_header() { |
| 2956 | - _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-header\' )' ); |
|
| 2957 | - return remove_theme_support( 'custom-header' ); |
|
| 2956 | + _deprecated_function(__FUNCTION__, '3.4', 'remove_theme_support( \'custom-header\' )'); |
|
| 2957 | + return remove_theme_support('custom-header'); |
|
| 2958 | 2958 | } |
| 2959 | 2959 | |
| 2960 | 2960 | /** |
@@ -2968,16 +2968,16 @@ discard block |
||
| 2968 | 2968 | * @param callback $admin_head_callback Call on custom background administration screen. |
| 2969 | 2969 | * @param callback $admin_preview_callback Output a custom background image div on the custom background administration screen. Optional. |
| 2970 | 2970 | */ |
| 2971 | -function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { |
|
| 2972 | - _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-background\', $args )' ); |
|
| 2971 | +function add_custom_background($wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '') { |
|
| 2972 | + _deprecated_function(__FUNCTION__, '3.4', 'add_theme_support( \'custom-background\', $args )'); |
|
| 2973 | 2973 | $args = array(); |
| 2974 | - if ( $wp_head_callback ) |
|
| 2974 | + if ($wp_head_callback) |
|
| 2975 | 2975 | $args['wp-head-callback'] = $wp_head_callback; |
| 2976 | - if ( $admin_head_callback ) |
|
| 2976 | + if ($admin_head_callback) |
|
| 2977 | 2977 | $args['admin-head-callback'] = $admin_head_callback; |
| 2978 | - if ( $admin_preview_callback ) |
|
| 2978 | + if ($admin_preview_callback) |
|
| 2979 | 2979 | $args['admin-preview-callback'] = $admin_preview_callback; |
| 2980 | - return add_theme_support( 'custom-background', $args ); |
|
| 2980 | + return add_theme_support('custom-background', $args); |
|
| 2981 | 2981 | } |
| 2982 | 2982 | |
| 2983 | 2983 | /** |
@@ -2990,8 +2990,8 @@ discard block |
||
| 2990 | 2990 | * @return null|bool Whether support was removed. |
| 2991 | 2991 | */ |
| 2992 | 2992 | function remove_custom_background() { |
| 2993 | - _deprecated_function( __FUNCTION__, '3.4', 'remove_theme_support( \'custom-background\' )' ); |
|
| 2994 | - return remove_theme_support( 'custom-background' ); |
|
| 2993 | + _deprecated_function(__FUNCTION__, '3.4', 'remove_theme_support( \'custom-background\' )'); |
|
| 2994 | + return remove_theme_support('custom-background'); |
|
| 2995 | 2995 | } |
| 2996 | 2996 | |
| 2997 | 2997 | /** |
@@ -3004,9 +3004,9 @@ discard block |
||
| 3004 | 3004 | * @param string $theme_file Theme file path. |
| 3005 | 3005 | * @return array Theme data. |
| 3006 | 3006 | */ |
| 3007 | -function get_theme_data( $theme_file ) { |
|
| 3008 | - _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); |
|
| 3009 | - $theme = new WP_Theme( basename( dirname( $theme_file ) ), dirname( dirname( $theme_file ) ) ); |
|
| 3007 | +function get_theme_data($theme_file) { |
|
| 3008 | + _deprecated_function(__FUNCTION__, '3.4', 'wp_get_theme()'); |
|
| 3009 | + $theme = new WP_Theme(basename(dirname($theme_file)), dirname(dirname($theme_file))); |
|
| 3010 | 3010 | |
| 3011 | 3011 | $theme_data = array( |
| 3012 | 3012 | 'Name' => $theme->get('Name'), |
@@ -3022,9 +3022,9 @@ discard block |
||
| 3022 | 3022 | 'AuthorName' => $theme->get('Author'), |
| 3023 | 3023 | ); |
| 3024 | 3024 | |
| 3025 | - foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { |
|
| 3026 | - if ( ! isset( $theme_data[ $extra_header ] ) ) |
|
| 3027 | - $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
| 3025 | + foreach (apply_filters('extra_theme_headers', array()) as $extra_header) { |
|
| 3026 | + if ( ! isset($theme_data[$extra_header])) |
|
| 3027 | + $theme_data[$extra_header] = $theme->get($extra_header); |
|
| 3028 | 3028 | } |
| 3029 | 3029 | |
| 3030 | 3030 | return $theme_data; |
@@ -3041,10 +3041,10 @@ discard block |
||
| 3041 | 3041 | * |
| 3042 | 3042 | * @param array $pages list of page objects |
| 3043 | 3043 | */ |
| 3044 | -function update_page_cache( &$pages ) { |
|
| 3045 | - _deprecated_function( __FUNCTION__, '3.4', 'update_post_cache()' ); |
|
| 3044 | +function update_page_cache(&$pages) { |
|
| 3045 | + _deprecated_function(__FUNCTION__, '3.4', 'update_post_cache()'); |
|
| 3046 | 3046 | |
| 3047 | - update_post_cache( $pages ); |
|
| 3047 | + update_post_cache($pages); |
|
| 3048 | 3048 | } |
| 3049 | 3049 | |
| 3050 | 3050 | /** |
@@ -3059,10 +3059,10 @@ discard block |
||
| 3059 | 3059 | * |
| 3060 | 3060 | * @param int $id Page ID to clean |
| 3061 | 3061 | */ |
| 3062 | -function clean_page_cache( $id ) { |
|
| 3063 | - _deprecated_function( __FUNCTION__, '3.4', 'clean_post_cache()' ); |
|
| 3062 | +function clean_page_cache($id) { |
|
| 3063 | + _deprecated_function(__FUNCTION__, '3.4', 'clean_post_cache()'); |
|
| 3064 | 3064 | |
| 3065 | - clean_post_cache( $id ); |
|
| 3065 | + clean_post_cache($id); |
|
| 3066 | 3066 | } |
| 3067 | 3067 | |
| 3068 | 3068 | /** |
@@ -3077,9 +3077,9 @@ discard block |
||
| 3077 | 3077 | * @param string $action Nonce action. |
| 3078 | 3078 | * @return string Are you sure message. |
| 3079 | 3079 | */ |
| 3080 | -function wp_explain_nonce( $action ) { |
|
| 3081 | - _deprecated_function( __FUNCTION__, '3.4.1', 'wp_nonce_ays()' ); |
|
| 3082 | - return __( 'Are you sure you want to do this?' ); |
|
| 3080 | +function wp_explain_nonce($action) { |
|
| 3081 | + _deprecated_function(__FUNCTION__, '3.4.1', 'wp_nonce_ays()'); |
|
| 3082 | + return __('Are you sure you want to do this?'); |
|
| 3083 | 3083 | } |
| 3084 | 3084 | |
| 3085 | 3085 | /** |
@@ -3091,9 +3091,9 @@ discard block |
||
| 3091 | 3091 | * |
| 3092 | 3092 | * @param int $post_id An optional post ID. |
| 3093 | 3093 | */ |
| 3094 | -function sticky_class( $post_id = null ) { |
|
| 3095 | - _deprecated_function( __FUNCTION__, '3.5', 'post_class()' ); |
|
| 3096 | - if ( is_sticky( $post_id ) ) |
|
| 3094 | +function sticky_class($post_id = null) { |
|
| 3095 | + _deprecated_function(__FUNCTION__, '3.5', 'post_class()'); |
|
| 3096 | + if (is_sticky($post_id)) |
|
| 3097 | 3097 | echo ' sticky'; |
| 3098 | 3098 | } |
| 3099 | 3099 | |
@@ -3107,8 +3107,8 @@ discard block |
||
| 3107 | 3107 | * @deprecated 3.5.0 Use get_post_ancestors() |
| 3108 | 3108 | * @see get_post_ancestors() |
| 3109 | 3109 | */ |
| 3110 | -function _get_post_ancestors( &$post ) { |
|
| 3111 | - _deprecated_function( __FUNCTION__, '3.5' ); |
|
| 3110 | +function _get_post_ancestors(&$post) { |
|
| 3111 | + _deprecated_function(__FUNCTION__, '3.5'); |
|
| 3112 | 3112 | } |
| 3113 | 3113 | |
| 3114 | 3114 | /** |
@@ -3121,23 +3121,23 @@ discard block |
||
| 3121 | 3121 | * @param string $file Filename of the image to load. |
| 3122 | 3122 | * @return resource The resulting image resource on success, Error string on failure. |
| 3123 | 3123 | */ |
| 3124 | -function wp_load_image( $file ) { |
|
| 3125 | - _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); |
|
| 3124 | +function wp_load_image($file) { |
|
| 3125 | + _deprecated_function(__FUNCTION__, '3.5', 'wp_get_image_editor()'); |
|
| 3126 | 3126 | |
| 3127 | - if ( is_numeric( $file ) ) |
|
| 3128 | - $file = get_attached_file( $file ); |
|
| 3127 | + if (is_numeric($file)) |
|
| 3128 | + $file = get_attached_file($file); |
|
| 3129 | 3129 | |
| 3130 | - if ( ! is_file( $file ) ) |
|
| 3130 | + if ( ! is_file($file)) |
|
| 3131 | 3131 | return sprintf(__('File “%s” doesn’t exist?'), $file); |
| 3132 | 3132 | |
| 3133 | - if ( ! function_exists('imagecreatefromstring') ) |
|
| 3133 | + if ( ! function_exists('imagecreatefromstring')) |
|
| 3134 | 3134 | return __('The GD image library is not installed.'); |
| 3135 | 3135 | |
| 3136 | 3136 | // Set artificially high because GD uses uncompressed images in memory |
| 3137 | - @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
| 3138 | - $image = imagecreatefromstring( file_get_contents( $file ) ); |
|
| 3137 | + @ini_set('memory_limit', apply_filters('image_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 3138 | + $image = imagecreatefromstring(file_get_contents($file)); |
|
| 3139 | 3139 | |
| 3140 | - if ( !is_resource( $image ) ) |
|
| 3140 | + if ( ! is_resource($image)) |
|
| 3141 | 3141 | return sprintf(__('File “%s” is not an image.'), $file); |
| 3142 | 3142 | |
| 3143 | 3143 | return $image; |
@@ -3167,22 +3167,22 @@ discard block |
||
| 3167 | 3167 | * @param int $jpeg_quality Optional, default is 90. Image quality percentage. |
| 3168 | 3168 | * @return mixed WP_Error on failure. String with new destination path. |
| 3169 | 3169 | */ |
| 3170 | -function image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ) { |
|
| 3171 | - _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); |
|
| 3170 | +function image_resize($file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90) { |
|
| 3171 | + _deprecated_function(__FUNCTION__, '3.5', 'wp_get_image_editor()'); |
|
| 3172 | 3172 | |
| 3173 | - $editor = wp_get_image_editor( $file ); |
|
| 3174 | - if ( is_wp_error( $editor ) ) |
|
| 3173 | + $editor = wp_get_image_editor($file); |
|
| 3174 | + if (is_wp_error($editor)) |
|
| 3175 | 3175 | return $editor; |
| 3176 | - $editor->set_quality( $jpeg_quality ); |
|
| 3176 | + $editor->set_quality($jpeg_quality); |
|
| 3177 | 3177 | |
| 3178 | - $resized = $editor->resize( $max_w, $max_h, $crop ); |
|
| 3179 | - if ( is_wp_error( $resized ) ) |
|
| 3178 | + $resized = $editor->resize($max_w, $max_h, $crop); |
|
| 3179 | + if (is_wp_error($resized)) |
|
| 3180 | 3180 | return $resized; |
| 3181 | 3181 | |
| 3182 | - $dest_file = $editor->generate_filename( $suffix, $dest_path ); |
|
| 3183 | - $saved = $editor->save( $dest_file ); |
|
| 3182 | + $dest_file = $editor->generate_filename($suffix, $dest_path); |
|
| 3183 | + $saved = $editor->save($dest_file); |
|
| 3184 | 3184 | |
| 3185 | - if ( is_wp_error( $saved ) ) |
|
| 3185 | + if (is_wp_error($saved)) |
|
| 3186 | 3186 | return $saved; |
| 3187 | 3187 | |
| 3188 | 3188 | return $dest_file; |
@@ -3202,9 +3202,9 @@ discard block |
||
| 3202 | 3202 | * @param string $mode How to return result, either OBJECT, ARRAY_N, or ARRAY_A. |
| 3203 | 3203 | * @return WP_Post|null Post object or array holding post contents and information |
| 3204 | 3204 | */ |
| 3205 | -function wp_get_single_post( $postid = 0, $mode = OBJECT ) { |
|
| 3206 | - _deprecated_function( __FUNCTION__, '3.5', 'get_post()' ); |
|
| 3207 | - return get_post( $postid, $mode ); |
|
| 3205 | +function wp_get_single_post($postid = 0, $mode = OBJECT) { |
|
| 3206 | + _deprecated_function(__FUNCTION__, '3.5', 'get_post()'); |
|
| 3207 | + return get_post($postid, $mode); |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | /** |
@@ -3219,9 +3219,9 @@ discard block |
||
| 3219 | 3219 | * @return bool False if does not authenticate, true if username and password authenticates. |
| 3220 | 3220 | */ |
| 3221 | 3221 | function user_pass_ok($user_login, $user_pass) { |
| 3222 | - _deprecated_function( __FUNCTION__, '3.5', 'wp_authenticate()' ); |
|
| 3223 | - $user = wp_authenticate( $user_login, $user_pass ); |
|
| 3224 | - if ( is_wp_error( $user ) ) |
|
| 3222 | + _deprecated_function(__FUNCTION__, '3.5', 'wp_authenticate()'); |
|
| 3223 | + $user = wp_authenticate($user_login, $user_pass); |
|
| 3224 | + if (is_wp_error($user)) |
|
| 3225 | 3225 | return false; |
| 3226 | 3226 | |
| 3227 | 3227 | return true; |
@@ -3246,10 +3246,10 @@ discard block |
||
| 3246 | 3246 | * @return bool |
| 3247 | 3247 | */ |
| 3248 | 3248 | function gd_edit_image_support($mime_type) { |
| 3249 | - _deprecated_function( __FUNCTION__, '3.5', 'wp_image_editor_supports()' ); |
|
| 3249 | + _deprecated_function(__FUNCTION__, '3.5', 'wp_image_editor_supports()'); |
|
| 3250 | 3250 | |
| 3251 | - if ( function_exists('imagetypes') ) { |
|
| 3252 | - switch( $mime_type ) { |
|
| 3251 | + if (function_exists('imagetypes')) { |
|
| 3252 | + switch ($mime_type) { |
|
| 3253 | 3253 | case 'image/jpeg': |
| 3254 | 3254 | return (imagetypes() & IMG_JPG) != 0; |
| 3255 | 3255 | case 'image/png': |
@@ -3258,7 +3258,7 @@ discard block |
||
| 3258 | 3258 | return (imagetypes() & IMG_GIF) != 0; |
| 3259 | 3259 | } |
| 3260 | 3260 | } else { |
| 3261 | - switch( $mime_type ) { |
|
| 3261 | + switch ($mime_type) { |
|
| 3262 | 3262 | case 'image/jpeg': |
| 3263 | 3263 | return function_exists('imagecreatefromjpeg'); |
| 3264 | 3264 | case 'image/png': |
@@ -3280,22 +3280,22 @@ discard block |
||
| 3280 | 3280 | * @param int $bytes An integer byte value. |
| 3281 | 3281 | * @return string A shorthand byte value. |
| 3282 | 3282 | */ |
| 3283 | -function wp_convert_bytes_to_hr( $bytes ) { |
|
| 3284 | - _deprecated_function( __FUNCTION__, '3.6', 'size_format()' ); |
|
| 3283 | +function wp_convert_bytes_to_hr($bytes) { |
|
| 3284 | + _deprecated_function(__FUNCTION__, '3.6', 'size_format()'); |
|
| 3285 | 3285 | |
| 3286 | - $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); |
|
| 3287 | - $log = log( $bytes, 1024 ); |
|
| 3286 | + $units = array(0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB', 4 => 'TB'); |
|
| 3287 | + $log = log($bytes, 1024); |
|
| 3288 | 3288 | $power = (int) $log; |
| 3289 | - $size = pow( 1024, $log - $power ); |
|
| 3289 | + $size = pow(1024, $log - $power); |
|
| 3290 | 3290 | |
| 3291 | - if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { |
|
| 3292 | - $unit = $units[ $power ]; |
|
| 3291 | + if ( ! is_nan($size) && array_key_exists($power, $units)) { |
|
| 3292 | + $unit = $units[$power]; |
|
| 3293 | 3293 | } else { |
| 3294 | 3294 | $size = $bytes; |
| 3295 | 3295 | $unit = $units[0]; |
| 3296 | 3296 | } |
| 3297 | 3297 | |
| 3298 | - return $size . $unit; |
|
| 3298 | + return $size.$unit; |
|
| 3299 | 3299 | } |
| 3300 | 3300 | |
| 3301 | 3301 | /** |
@@ -3305,9 +3305,9 @@ discard block |
||
| 3305 | 3305 | * @access private |
| 3306 | 3306 | * @deprecated 3.7.0 |
| 3307 | 3307 | */ |
| 3308 | -function _search_terms_tidy( $t ) { |
|
| 3309 | - _deprecated_function( __FUNCTION__, '3.7' ); |
|
| 3310 | - return trim( $t, "\"'\n\r " ); |
|
| 3308 | +function _search_terms_tidy($t) { |
|
| 3309 | + _deprecated_function(__FUNCTION__, '3.7'); |
|
| 3310 | + return trim($t, "\"'\n\r "); |
|
| 3311 | 3311 | } |
| 3312 | 3312 | |
| 3313 | 3313 | /** |
@@ -3323,10 +3323,10 @@ discard block |
||
| 3323 | 3323 | */ |
| 3324 | 3324 | function rich_edit_exists() { |
| 3325 | 3325 | global $wp_rich_edit_exists; |
| 3326 | - _deprecated_function( __FUNCTION__, '3.9' ); |
|
| 3326 | + _deprecated_function(__FUNCTION__, '3.9'); |
|
| 3327 | 3327 | |
| 3328 | - if ( ! isset( $wp_rich_edit_exists ) ) |
|
| 3329 | - $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
| 3328 | + if ( ! isset($wp_rich_edit_exists)) |
|
| 3329 | + $wp_rich_edit_exists = file_exists(ABSPATH.WPINC.'/js/tinymce/tinymce.js'); |
|
| 3330 | 3330 | |
| 3331 | 3331 | return $wp_rich_edit_exists; |
| 3332 | 3332 | } |
@@ -3338,7 +3338,7 @@ discard block |
||
| 3338 | 3338 | * @access private |
| 3339 | 3339 | * @deprecated 3.9.0 |
| 3340 | 3340 | */ |
| 3341 | -function default_topic_count_text( $count ) { |
|
| 3341 | +function default_topic_count_text($count) { |
|
| 3342 | 3342 | return $count; |
| 3343 | 3343 | } |
| 3344 | 3344 | |
@@ -3353,8 +3353,8 @@ discard block |
||
| 3353 | 3353 | * @param string $content The text to format. |
| 3354 | 3354 | * @return string The very same text. |
| 3355 | 3355 | */ |
| 3356 | -function format_to_post( $content ) { |
|
| 3357 | - _deprecated_function( __FUNCTION__, '3.9' ); |
|
| 3356 | +function format_to_post($content) { |
|
| 3357 | + _deprecated_function(__FUNCTION__, '3.9'); |
|
| 3358 | 3358 | return $content; |
| 3359 | 3359 | } |
| 3360 | 3360 | |
@@ -3369,8 +3369,8 @@ discard block |
||
| 3369 | 3369 | * @return string text, safe for inclusion in LIKE query. |
| 3370 | 3370 | */ |
| 3371 | 3371 | function like_escape($text) { |
| 3372 | - _deprecated_function( __FUNCTION__, '4.0', 'wpdb::esc_like()' ); |
|
| 3373 | - return str_replace( array( "%", "_" ), array( "\\%", "\\_" ), $text ); |
|
| 3372 | + _deprecated_function(__FUNCTION__, '4.0', 'wpdb::esc_like()'); |
|
| 3373 | + return str_replace(array("%", "_"), array("\\%", "\\_"), $text); |
|
| 3374 | 3374 | } |
| 3375 | 3375 | |
| 3376 | 3376 | /** |
@@ -3385,14 +3385,14 @@ discard block |
||
| 3385 | 3385 | * @param string $url The URL to test. |
| 3386 | 3386 | * @return bool Whether SSL access is available. |
| 3387 | 3387 | */ |
| 3388 | -function url_is_accessable_via_ssl( $url ) { |
|
| 3389 | - _deprecated_function( __FUNCTION__, '4.0' ); |
|
| 3388 | +function url_is_accessable_via_ssl($url) { |
|
| 3389 | + _deprecated_function(__FUNCTION__, '4.0'); |
|
| 3390 | 3390 | |
| 3391 | - $response = wp_remote_get( set_url_scheme( $url, 'https' ) ); |
|
| 3391 | + $response = wp_remote_get(set_url_scheme($url, 'https')); |
|
| 3392 | 3392 | |
| 3393 | - if ( !is_wp_error( $response ) ) { |
|
| 3394 | - $status = wp_remote_retrieve_response_code( $response ); |
|
| 3395 | - if ( 200 == $status || 401 == $status ) { |
|
| 3393 | + if ( ! is_wp_error($response)) { |
|
| 3394 | + $status = wp_remote_retrieve_response_code($response); |
|
| 3395 | + if (200 == $status || 401 == $status) { |
|
| 3396 | 3396 | return true; |
| 3397 | 3397 | } |
| 3398 | 3398 | } |
@@ -3410,7 +3410,7 @@ discard block |
||
| 3410 | 3410 | * @deprecated 4.3.0 |
| 3411 | 3411 | */ |
| 3412 | 3412 | function preview_theme() { |
| 3413 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
| 3413 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
| 3414 | 3414 | } |
| 3415 | 3415 | |
| 3416 | 3416 | /** |
@@ -3423,7 +3423,7 @@ discard block |
||
| 3423 | 3423 | * @return string |
| 3424 | 3424 | */ |
| 3425 | 3425 | function _preview_theme_template_filter() { |
| 3426 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
| 3426 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
| 3427 | 3427 | return ''; |
| 3428 | 3428 | } |
| 3429 | 3429 | |
@@ -3437,7 +3437,7 @@ discard block |
||
| 3437 | 3437 | * @return string |
| 3438 | 3438 | */ |
| 3439 | 3439 | function _preview_theme_stylesheet_filter() { |
| 3440 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
| 3440 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
| 3441 | 3441 | return ''; |
| 3442 | 3442 | } |
| 3443 | 3443 | |
@@ -3451,8 +3451,8 @@ discard block |
||
| 3451 | 3451 | * @param string $content |
| 3452 | 3452 | * @return string |
| 3453 | 3453 | */ |
| 3454 | -function preview_theme_ob_filter( $content ) { |
|
| 3455 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
| 3454 | +function preview_theme_ob_filter($content) { |
|
| 3455 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
| 3456 | 3456 | return $content; |
| 3457 | 3457 | } |
| 3458 | 3458 | |
@@ -3468,8 +3468,8 @@ discard block |
||
| 3468 | 3468 | * @param array $matches |
| 3469 | 3469 | * @return string |
| 3470 | 3470 | */ |
| 3471 | -function preview_theme_ob_filter_callback( $matches ) { |
|
| 3472 | - _deprecated_function( __FUNCTION__, '4.3' ); |
|
| 3471 | +function preview_theme_ob_filter_callback($matches) { |
|
| 3472 | + _deprecated_function(__FUNCTION__, '4.3'); |
|
| 3473 | 3473 | return ''; |
| 3474 | 3474 | } |
| 3475 | 3475 | |
@@ -3486,9 +3486,9 @@ discard block |
||
| 3486 | 3486 | * @return string The formatted text after filter is applied. |
| 3487 | 3487 | */ |
| 3488 | 3488 | function wp_richedit_pre($text) { |
| 3489 | - _deprecated_function( __FUNCTION__, '4.3', 'format_for_editor()' ); |
|
| 3489 | + _deprecated_function(__FUNCTION__, '4.3', 'format_for_editor()'); |
|
| 3490 | 3490 | |
| 3491 | - if ( empty( $text ) ) { |
|
| 3491 | + if (empty($text)) { |
|
| 3492 | 3492 | /** |
| 3493 | 3493 | * Filter text returned for the rich text editor. |
| 3494 | 3494 | * |
@@ -3504,15 +3504,15 @@ discard block |
||
| 3504 | 3504 | * |
| 3505 | 3505 | * @param string $output Text for the rich text editor. |
| 3506 | 3506 | */ |
| 3507 | - return apply_filters( 'richedit_pre', '' ); |
|
| 3507 | + return apply_filters('richedit_pre', ''); |
|
| 3508 | 3508 | } |
| 3509 | 3509 | |
| 3510 | 3510 | $output = convert_chars($text); |
| 3511 | 3511 | $output = wpautop($output); |
| 3512 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
|
| 3512 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option('blog_charset')); |
|
| 3513 | 3513 | |
| 3514 | 3514 | /** This filter is documented in wp-includes/deprecated.php */ |
| 3515 | - return apply_filters( 'richedit_pre', $output ); |
|
| 3515 | + return apply_filters('richedit_pre', $output); |
|
| 3516 | 3516 | } |
| 3517 | 3517 | |
| 3518 | 3518 | /** |
@@ -3529,10 +3529,10 @@ discard block |
||
| 3529 | 3529 | * @return string Formatted text after filter applied. |
| 3530 | 3530 | */ |
| 3531 | 3531 | function wp_htmledit_pre($output) { |
| 3532 | - _deprecated_function( __FUNCTION__, '4.3', 'format_for_editor()' ); |
|
| 3532 | + _deprecated_function(__FUNCTION__, '4.3', 'format_for_editor()'); |
|
| 3533 | 3533 | |
| 3534 | - if ( !empty($output) ) |
|
| 3535 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & |
|
| 3534 | + if ( ! empty($output)) |
|
| 3535 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option('blog_charset')); // convert only < > & |
|
| 3536 | 3536 | |
| 3537 | 3537 | /** |
| 3538 | 3538 | * Filter the text before it is formatted for the HTML editor. |
@@ -3542,7 +3542,7 @@ discard block |
||
| 3542 | 3542 | * |
| 3543 | 3543 | * @param string $output The HTML-formatted text. |
| 3544 | 3544 | */ |
| 3545 | - return apply_filters( 'htmledit_pre', $output ); |
|
| 3545 | + return apply_filters('htmledit_pre', $output); |
|
| 3546 | 3546 | } |
| 3547 | 3547 | |
| 3548 | 3548 | /** |
@@ -3555,9 +3555,9 @@ discard block |
||
| 3555 | 3555 | * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
| 3556 | 3556 | * @return string|false |
| 3557 | 3557 | */ |
| 3558 | -function post_permalink( $post_id = 0 ) { |
|
| 3559 | - _deprecated_function( __FUNCTION__, '4.4', 'get_permalink()' ); |
|
| 3558 | +function post_permalink($post_id = 0) { |
|
| 3559 | + _deprecated_function(__FUNCTION__, '4.4', 'get_permalink()'); |
|
| 3560 | 3560 | |
| 3561 | - return get_permalink( $post_id ); |
|
| 3561 | + return get_permalink($post_id); |
|
| 3562 | 3562 | } |
| 3563 | 3563 | |
@@ -86,8 +86,9 @@ discard block |
||
| 86 | 86 | $categories = get_the_category(); |
| 87 | 87 | $cat = $categories[0]->term_id; |
| 88 | 88 | |
| 89 | - if ( $echo ) |
|
| 90 | - echo $cat; |
|
| 89 | + if ( $echo ) { |
|
| 90 | + echo $cat; |
|
| 91 | + } |
|
| 91 | 92 | |
| 92 | 93 | return $cat; |
| 93 | 94 | } |
@@ -136,19 +137,22 @@ discard block |
||
| 136 | 137 | |
| 137 | 138 | _deprecated_function( __FUNCTION__, '2.0', 'previous_post_link()' ); |
| 138 | 139 | |
| 139 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
| 140 | - $in_same_cat = false; |
|
| 141 | - else |
|
| 142 | - $in_same_cat = true; |
|
| 140 | + if ( empty($in_same_cat) || 'no' == $in_same_cat ) { |
|
| 141 | + $in_same_cat = false; |
|
| 142 | + } else { |
|
| 143 | + $in_same_cat = true; |
|
| 144 | + } |
|
| 143 | 145 | |
| 144 | 146 | $post = get_previous_post($in_same_cat, $excluded_categories); |
| 145 | 147 | |
| 146 | - if ( !$post ) |
|
| 147 | - return; |
|
| 148 | + if ( !$post ) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | $string = '<a href="'.get_permalink($post->ID).'">'.$previous; |
| 150 | - if ( 'yes' == $title ) |
|
| 151 | - $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
| 153 | + if ( 'yes' == $title ) { |
|
| 154 | + $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
| 155 | + } |
|
| 152 | 156 | $string .= '</a>'; |
| 153 | 157 | $format = str_replace('%', $string, $format); |
| 154 | 158 | echo $format; |
@@ -171,19 +175,22 @@ discard block |
||
| 171 | 175 | function next_post($format='%', $next='next post: ', $title='yes', $in_same_cat='no', $limitnext=1, $excluded_categories='') { |
| 172 | 176 | _deprecated_function( __FUNCTION__, '2.0', 'next_post_link()' ); |
| 173 | 177 | |
| 174 | - if ( empty($in_same_cat) || 'no' == $in_same_cat ) |
|
| 175 | - $in_same_cat = false; |
|
| 176 | - else |
|
| 177 | - $in_same_cat = true; |
|
| 178 | + if ( empty($in_same_cat) || 'no' == $in_same_cat ) { |
|
| 179 | + $in_same_cat = false; |
|
| 180 | + } else { |
|
| 181 | + $in_same_cat = true; |
|
| 182 | + } |
|
| 178 | 183 | |
| 179 | 184 | $post = get_next_post($in_same_cat, $excluded_categories); |
| 180 | 185 | |
| 181 | - if ( !$post ) |
|
| 182 | - return; |
|
| 186 | + if ( !$post ) { |
|
| 187 | + return; |
|
| 188 | + } |
|
| 183 | 189 | |
| 184 | 190 | $string = '<a href="'.get_permalink($post->ID).'">'.$next; |
| 185 | - if ( 'yes' == $title ) |
|
| 186 | - $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
| 191 | + if ( 'yes' == $title ) { |
|
| 192 | + $string .= apply_filters('the_title', $post->post_title, $post->ID); |
|
| 193 | + } |
|
| 187 | 194 | $string .= '</a>'; |
| 188 | 195 | $format = str_replace('%', $string, $format); |
| 189 | 196 | echo $format; |
@@ -366,11 +373,12 @@ discard block |
||
| 366 | 373 | |
| 367 | 374 | $user = get_userdata($user_id); |
| 368 | 375 | $other = get_userdata($other_user); |
| 369 | - if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) |
|
| 370 | - return true; |
|
| 371 | - else |
|
| 372 | - return false; |
|
| 373 | -} |
|
| 376 | + if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID ) { |
|
| 377 | + return true; |
|
| 378 | + } else { |
|
| 379 | + return false; |
|
| 380 | + } |
|
| 381 | + } |
|
| 374 | 382 | |
| 375 | 383 | /** |
| 376 | 384 | * Gets the links associated with category $cat_name. |
@@ -399,8 +407,9 @@ discard block |
||
| 399 | 407 | |
| 400 | 408 | $cat_id = -1; |
| 401 | 409 | $cat = get_term_by('name', $cat_name, 'link_category'); |
| 402 | - if ( $cat ) |
|
| 403 | - $cat_id = $cat->term_id; |
|
| 410 | + if ( $cat ) { |
|
| 411 | + $cat_id = $cat->term_id; |
|
| 412 | + } |
|
| 404 | 413 | |
| 405 | 414 | get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); |
| 406 | 415 | } |
@@ -459,8 +468,9 @@ discard block |
||
| 459 | 468 | |
| 460 | 469 | $cat_id = -1; |
| 461 | 470 | $cat = get_term_by('name', $cat_name, 'link_category'); |
| 462 | - if ( $cat ) |
|
| 463 | - $cat_id = $cat->term_id; |
|
| 471 | + if ( $cat ) { |
|
| 472 | + $cat_id = $cat->term_id; |
|
| 473 | + } |
|
| 464 | 474 | |
| 465 | 475 | return get_linkobjects($cat_id, $orderby, $limit); |
| 466 | 476 | } |
@@ -511,8 +521,9 @@ discard block |
||
| 511 | 521 | $links = get_bookmarks( array( 'category' => $category, 'orderby' => $orderby, 'limit' => $limit ) ) ; |
| 512 | 522 | |
| 513 | 523 | $links_array = array(); |
| 514 | - foreach ($links as $link) |
|
| 515 | - $links_array[] = $link; |
|
| 524 | + foreach ($links as $link) { |
|
| 525 | + $links_array[] = $link; |
|
| 526 | + } |
|
| 516 | 527 | |
| 517 | 528 | return $links_array; |
| 518 | 529 | } |
@@ -638,18 +649,24 @@ discard block |
||
| 638 | 649 | $r = wp_parse_args( $args ); |
| 639 | 650 | |
| 640 | 651 | // Map to new names. |
| 641 | - if ( isset($r['optionall']) && isset($r['all'])) |
|
| 642 | - $r['show_option_all'] = $r['all']; |
|
| 643 | - if ( isset($r['sort_column']) ) |
|
| 644 | - $r['orderby'] = $r['sort_column']; |
|
| 645 | - if ( isset($r['sort_order']) ) |
|
| 646 | - $r['order'] = $r['sort_order']; |
|
| 647 | - if ( isset($r['optiondates']) ) |
|
| 648 | - $r['show_last_update'] = $r['optiondates']; |
|
| 649 | - if ( isset($r['optioncount']) ) |
|
| 650 | - $r['show_count'] = $r['optioncount']; |
|
| 651 | - if ( isset($r['list']) ) |
|
| 652 | - $r['style'] = $r['list'] ? 'list' : 'break'; |
|
| 652 | + if ( isset($r['optionall']) && isset($r['all'])) { |
|
| 653 | + $r['show_option_all'] = $r['all']; |
|
| 654 | + } |
|
| 655 | + if ( isset($r['sort_column']) ) { |
|
| 656 | + $r['orderby'] = $r['sort_column']; |
|
| 657 | + } |
|
| 658 | + if ( isset($r['sort_order']) ) { |
|
| 659 | + $r['order'] = $r['sort_order']; |
|
| 660 | + } |
|
| 661 | + if ( isset($r['optiondates']) ) { |
|
| 662 | + $r['show_last_update'] = $r['optiondates']; |
|
| 663 | + } |
|
| 664 | + if ( isset($r['optioncount']) ) { |
|
| 665 | + $r['show_count'] = $r['optioncount']; |
|
| 666 | + } |
|
| 667 | + if ( isset($r['list']) ) { |
|
| 668 | + $r['style'] = $r['list'] ? 'list' : 'break'; |
|
| 669 | + } |
|
| 653 | 670 | $r['title_li'] = ''; |
| 654 | 671 | |
| 655 | 672 | return wp_list_categories($r); |
@@ -680,12 +697,14 @@ discard block |
||
| 680 | 697 | _deprecated_function( __FUNCTION__, '2.1', 'wp_dropdown_categories()' ); |
| 681 | 698 | |
| 682 | 699 | $show_option_all = ''; |
| 683 | - if ( $optionall ) |
|
| 684 | - $show_option_all = $all; |
|
| 700 | + if ( $optionall ) { |
|
| 701 | + $show_option_all = $all; |
|
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | $show_option_none = ''; |
| 687 | - if ( $optionnone ) |
|
| 688 | - $show_option_none = __('None'); |
|
| 705 | + if ( $optionnone ) { |
|
| 706 | + $show_option_none = __('None'); |
|
| 707 | + } |
|
| 689 | 708 | |
| 690 | 709 | $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', |
| 691 | 710 | 'show_last_update', 'show_count', 'hide_empty', 'selected', 'exclude'); |
@@ -787,8 +806,9 @@ discard block |
||
| 787 | 806 | |
| 788 | 807 | $link = get_author_posts_url($author_id, $author_nicename); |
| 789 | 808 | |
| 790 | - if ( $echo ) |
|
| 791 | - echo $link; |
|
| 809 | + if ( $echo ) { |
|
| 810 | + echo $link; |
|
| 811 | + } |
|
| 792 | 812 | return $link; |
| 793 | 813 | } |
| 794 | 814 | |
@@ -931,64 +951,78 @@ discard block |
||
| 931 | 951 | $orderby = substr($orderby, 1); |
| 932 | 952 | } |
| 933 | 953 | |
| 934 | - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories |
|
| 954 | + if ( $category == -1 ) { |
|
| 955 | + //get_bookmarks uses '' to signify all categories |
|
| 935 | 956 | $category = ''; |
| 957 | + } |
|
| 936 | 958 | |
| 937 | 959 | $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); |
| 938 | 960 | |
| 939 | - if ( !$results ) |
|
| 940 | - return; |
|
| 961 | + if ( !$results ) { |
|
| 962 | + return; |
|
| 963 | + } |
|
| 941 | 964 | |
| 942 | 965 | $output = ''; |
| 943 | 966 | |
| 944 | 967 | foreach ( (array) $results as $row ) { |
| 945 | - if ( !isset($row->recently_updated) ) |
|
| 946 | - $row->recently_updated = false; |
|
| 968 | + if ( !isset($row->recently_updated) ) { |
|
| 969 | + $row->recently_updated = false; |
|
| 970 | + } |
|
| 947 | 971 | $output .= $before; |
| 948 | - if ( $show_updated && $row->recently_updated ) |
|
| 949 | - $output .= get_option('links_recently_updated_prepend'); |
|
| 972 | + if ( $show_updated && $row->recently_updated ) { |
|
| 973 | + $output .= get_option('links_recently_updated_prepend'); |
|
| 974 | + } |
|
| 950 | 975 | $the_link = '#'; |
| 951 | - if ( !empty($row->link_url) ) |
|
| 952 | - $the_link = esc_url($row->link_url); |
|
| 976 | + if ( !empty($row->link_url) ) { |
|
| 977 | + $the_link = esc_url($row->link_url); |
|
| 978 | + } |
|
| 953 | 979 | $rel = $row->link_rel; |
| 954 | - if ( '' != $rel ) |
|
| 955 | - $rel = ' rel="' . $rel . '"'; |
|
| 980 | + if ( '' != $rel ) { |
|
| 981 | + $rel = ' rel="' . $rel . '"'; |
|
| 982 | + } |
|
| 956 | 983 | |
| 957 | 984 | $desc = esc_attr(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); |
| 958 | 985 | $name = esc_attr(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); |
| 959 | 986 | $title = $desc; |
| 960 | 987 | |
| 961 | - if ( $show_updated ) |
|
| 962 | - if (substr($row->link_updated_f, 0, 2) != '00') |
|
| 988 | + if ( $show_updated ) { |
|
| 989 | + if (substr($row->link_updated_f, 0, 2) != '00') |
|
| 963 | 990 | $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')'; |
| 991 | + } |
|
| 964 | 992 | |
| 965 | - if ( '' != $title ) |
|
| 966 | - $title = ' title="' . $title . '"'; |
|
| 993 | + if ( '' != $title ) { |
|
| 994 | + $title = ' title="' . $title . '"'; |
|
| 995 | + } |
|
| 967 | 996 | |
| 968 | 997 | $alt = ' alt="' . $name . '"'; |
| 969 | 998 | |
| 970 | 999 | $target = $row->link_target; |
| 971 | - if ( '' != $target ) |
|
| 972 | - $target = ' target="' . $target . '"'; |
|
| 1000 | + if ( '' != $target ) { |
|
| 1001 | + $target = ' target="' . $target . '"'; |
|
| 1002 | + } |
|
| 973 | 1003 | |
| 974 | 1004 | $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; |
| 975 | 1005 | |
| 976 | 1006 | if ( $row->link_image != null && $show_images ) { |
| 977 | - if ( strpos($row->link_image, 'http') !== false ) |
|
| 978 | - $output .= "<img src=\"$row->link_image\" $alt $title />"; |
|
| 979 | - else // If it's a relative path |
|
| 1007 | + if ( strpos($row->link_image, 'http') !== false ) { |
|
| 1008 | + $output .= "<img src=\"$row->link_image\" $alt $title />"; |
|
| 1009 | + } else { |
|
| 1010 | + // If it's a relative path |
|
| 980 | 1011 | $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; |
| 1012 | + } |
|
| 981 | 1013 | } else { |
| 982 | 1014 | $output .= $name; |
| 983 | 1015 | } |
| 984 | 1016 | |
| 985 | 1017 | $output .= '</a>'; |
| 986 | 1018 | |
| 987 | - if ( $show_updated && $row->recently_updated ) |
|
| 988 | - $output .= get_option('links_recently_updated_append'); |
|
| 1019 | + if ( $show_updated && $row->recently_updated ) { |
|
| 1020 | + $output .= get_option('links_recently_updated_append'); |
|
| 1021 | + } |
|
| 989 | 1022 | |
| 990 | - if ( $show_description && '' != $desc ) |
|
| 991 | - $output .= $between . $desc; |
|
| 1023 | + if ( $show_description && '' != $desc ) { |
|
| 1024 | + $output .= $between . $desc; |
|
| 1025 | + } |
|
| 992 | 1026 | |
| 993 | 1027 | if ($show_rating) { |
| 994 | 1028 | $output .= $between . get_linkrating($row); |
@@ -997,8 +1031,9 @@ discard block |
||
| 997 | 1031 | $output .= "$after\n"; |
| 998 | 1032 | } // end while |
| 999 | 1033 | |
| 1000 | - if ( !$echo ) |
|
| 1001 | - return $output; |
|
| 1034 | + if ( !$echo ) { |
|
| 1035 | + return $output; |
|
| 1036 | + } |
|
| 1002 | 1037 | echo $output; |
| 1003 | 1038 | } |
| 1004 | 1039 | |
@@ -1026,8 +1061,9 @@ discard block |
||
| 1026 | 1061 | $order = substr($order,1); |
| 1027 | 1062 | } |
| 1028 | 1063 | |
| 1029 | - if ( !isset($direction) ) |
|
| 1030 | - $direction = ''; |
|
| 1064 | + if ( !isset($direction) ) { |
|
| 1065 | + $direction = ''; |
|
| 1066 | + } |
|
| 1031 | 1067 | |
| 1032 | 1068 | $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); |
| 1033 | 1069 | |
@@ -1091,13 +1127,15 @@ discard block |
||
| 1091 | 1127 | |
| 1092 | 1128 | $id = (int) $id; |
| 1093 | 1129 | |
| 1094 | - if ( empty($id) ) |
|
| 1095 | - return ''; |
|
| 1130 | + if ( empty($id) ) { |
|
| 1131 | + return ''; |
|
| 1132 | + } |
|
| 1096 | 1133 | |
| 1097 | 1134 | $cats = wp_get_link_cats($id); |
| 1098 | 1135 | |
| 1099 | - if ( empty($cats) || ! is_array($cats) ) |
|
| 1100 | - return ''; |
|
| 1136 | + if ( empty($cats) || ! is_array($cats) ) { |
|
| 1137 | + return ''; |
|
| 1138 | + } |
|
| 1101 | 1139 | |
| 1102 | 1140 | $cat_id = (int) $cats[0]; // Take the first cat. |
| 1103 | 1141 | |
@@ -1135,8 +1173,9 @@ discard block |
||
| 1135 | 1173 | |
| 1136 | 1174 | $link = get_category_feed_link($cat_ID, 'rss2'); |
| 1137 | 1175 | |
| 1138 | - if ( $echo ) |
|
| 1139 | - echo $link; |
|
| 1176 | + if ( $echo ) { |
|
| 1177 | + echo $link; |
|
| 1178 | + } |
|
| 1140 | 1179 | return $link; |
| 1141 | 1180 | } |
| 1142 | 1181 | |
@@ -1155,8 +1194,9 @@ discard block |
||
| 1155 | 1194 | _deprecated_function( __FUNCTION__, '2.5', 'get_author_feed_link()' ); |
| 1156 | 1195 | |
| 1157 | 1196 | $link = get_author_feed_link($author_id); |
| 1158 | - if ( $echo ) |
|
| 1159 | - echo $link; |
|
| 1197 | + if ( $echo ) { |
|
| 1198 | + echo $link; |
|
| 1199 | + } |
|
| 1160 | 1200 | return $link; |
| 1161 | 1201 | } |
| 1162 | 1202 | |
@@ -1248,19 +1288,22 @@ discard block |
||
| 1248 | 1288 | */ |
| 1249 | 1289 | function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { |
| 1250 | 1290 | _deprecated_function( __FUNCTION__, '2.8', 'get_term_children()' ); |
| 1251 | - if ( 0 == $id ) |
|
| 1252 | - return ''; |
|
| 1291 | + if ( 0 == $id ) { |
|
| 1292 | + return ''; |
|
| 1293 | + } |
|
| 1253 | 1294 | |
| 1254 | 1295 | $chain = ''; |
| 1255 | 1296 | /** TODO: consult hierarchy */ |
| 1256 | 1297 | $cat_ids = get_all_category_ids(); |
| 1257 | 1298 | foreach ( (array) $cat_ids as $cat_id ) { |
| 1258 | - if ( $cat_id == $id ) |
|
| 1259 | - continue; |
|
| 1299 | + if ( $cat_id == $id ) { |
|
| 1300 | + continue; |
|
| 1301 | + } |
|
| 1260 | 1302 | |
| 1261 | 1303 | $category = get_category( $cat_id ); |
| 1262 | - if ( is_wp_error( $category ) ) |
|
| 1263 | - return $category; |
|
| 1304 | + if ( is_wp_error( $category ) ) { |
|
| 1305 | + return $category; |
|
| 1306 | + } |
|
| 1264 | 1307 | if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { |
| 1265 | 1308 | $visited[] = $category->term_id; |
| 1266 | 1309 | $chain .= $before.$category->term_id.$after; |
@@ -1651,8 +1694,9 @@ discard block |
||
| 1651 | 1694 | _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' ); |
| 1652 | 1695 | $content = get_the_content($more_link_text, $stripteaser); |
| 1653 | 1696 | $content = apply_filters('the_content_rss', $content); |
| 1654 | - if ( $cut && !$encode_html ) |
|
| 1655 | - $encode_html = 2; |
|
| 1697 | + if ( $cut && !$encode_html ) { |
|
| 1698 | + $encode_html = 2; |
|
| 1699 | + } |
|
| 1656 | 1700 | if ( 1== $encode_html ) { |
| 1657 | 1701 | $content = esc_html($content); |
| 1658 | 1702 | $cut = 0; |
@@ -1672,8 +1716,9 @@ discard block |
||
| 1672 | 1716 | } |
| 1673 | 1717 | |
| 1674 | 1718 | /** @todo Check performance, might be faster to use array slice instead. */ |
| 1675 | - for ( $i=0; $i<$k; $i++ ) |
|
| 1676 | - $excerpt .= $blah[$i].' '; |
|
| 1719 | + for ( $i=0; $i<$k; $i++ ) { |
|
| 1720 | + $excerpt .= $blah[$i].' '; |
|
| 1721 | + } |
|
| 1677 | 1722 | $excerpt .= ($use_dotdotdot) ? '...' : ''; |
| 1678 | 1723 | $content = $excerpt; |
| 1679 | 1724 | } |
@@ -1826,11 +1871,13 @@ discard block |
||
| 1826 | 1871 | $id = (int) $id; |
| 1827 | 1872 | $_post = get_post($id); |
| 1828 | 1873 | |
| 1829 | - if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) |
|
| 1830 | - return __('Missing Attachment'); |
|
| 1874 | + if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) { |
|
| 1875 | + return __('Missing Attachment'); |
|
| 1876 | + } |
|
| 1831 | 1877 | |
| 1832 | - if ( $permalink ) |
|
| 1833 | - $url = get_attachment_link($_post->ID); |
|
| 1878 | + if ( $permalink ) { |
|
| 1879 | + $url = get_attachment_link($_post->ID); |
|
| 1880 | + } |
|
| 1834 | 1881 | |
| 1835 | 1882 | $post_title = esc_attr($_post->post_title); |
| 1836 | 1883 | |
@@ -1852,8 +1899,9 @@ discard block |
||
| 1852 | 1899 | function get_attachment_icon_src( $id = 0, $fullsize = false ) { |
| 1853 | 1900 | _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); |
| 1854 | 1901 | $id = (int) $id; |
| 1855 | - if ( !$post = get_post($id) ) |
|
| 1856 | - return false; |
|
| 1902 | + if ( !$post = get_post($id) ) { |
|
| 1903 | + return false; |
|
| 1904 | + } |
|
| 1857 | 1905 | |
| 1858 | 1906 | $file = get_attached_file( $post->ID ); |
| 1859 | 1907 | |
@@ -1873,8 +1921,9 @@ discard block |
||
| 1873 | 1921 | $src_file = $icon_dir . '/' . basename($src); |
| 1874 | 1922 | } |
| 1875 | 1923 | |
| 1876 | - if ( !isset($src) || !$src ) |
|
| 1877 | - return false; |
|
| 1924 | + if ( !isset($src) || !$src ) { |
|
| 1925 | + return false; |
|
| 1926 | + } |
|
| 1878 | 1927 | |
| 1879 | 1928 | return array($src, $src_file); |
| 1880 | 1929 | } |
@@ -1894,11 +1943,13 @@ discard block |
||
| 1894 | 1943 | function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { |
| 1895 | 1944 | _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); |
| 1896 | 1945 | $id = (int) $id; |
| 1897 | - if ( !$post = get_post($id) ) |
|
| 1898 | - return false; |
|
| 1946 | + if ( !$post = get_post($id) ) { |
|
| 1947 | + return false; |
|
| 1948 | + } |
|
| 1899 | 1949 | |
| 1900 | - if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) |
|
| 1901 | - return false; |
|
| 1950 | + if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) { |
|
| 1951 | + return false; |
|
| 1952 | + } |
|
| 1902 | 1953 | |
| 1903 | 1954 | list($src, $src_file) = $src; |
| 1904 | 1955 | |
@@ -1950,11 +2001,13 @@ discard block |
||
| 1950 | 2001 | function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { |
| 1951 | 2002 | _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); |
| 1952 | 2003 | $id = (int) $id; |
| 1953 | - if ( !$post = get_post($id) ) |
|
| 1954 | - return false; |
|
| 2004 | + if ( !$post = get_post($id) ) { |
|
| 2005 | + return false; |
|
| 2006 | + } |
|
| 1955 | 2007 | |
| 1956 | - if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) |
|
| 1957 | - return $innerHTML; |
|
| 2008 | + if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) { |
|
| 2009 | + return $innerHTML; |
|
| 2010 | + } |
|
| 1958 | 2011 | |
| 1959 | 2012 | $innerHTML = esc_attr($post->post_title); |
| 1960 | 2013 | |
@@ -2010,10 +2063,11 @@ discard block |
||
| 2010 | 2063 | * @return string The cleaned $url after the 'clean_url' filter is applied. |
| 2011 | 2064 | */ |
| 2012 | 2065 | function clean_url( $url, $protocols = null, $context = 'display' ) { |
| 2013 | - if ( $context == 'db' ) |
|
| 2014 | - _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' ); |
|
| 2015 | - else |
|
| 2016 | - _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' ); |
|
| 2066 | + if ( $context == 'db' ) { |
|
| 2067 | + _deprecated_function( 'clean_url( $context = \'db\' )', '3.0', 'esc_url_raw()' ); |
|
| 2068 | + } else { |
|
| 2069 | + _deprecated_function( __FUNCTION__, '3.0', 'esc_url()' ); |
|
| 2070 | + } |
|
| 2017 | 2071 | return esc_url( $url, $protocols, $context ); |
| 2018 | 2072 | } |
| 2019 | 2073 | |
@@ -2088,20 +2142,23 @@ discard block |
||
| 2088 | 2142 | _deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' ); |
| 2089 | 2143 | // Compat |
| 2090 | 2144 | if ( is_array($name) ) { |
| 2091 | - if ( count($name) == 3 ) |
|
| 2092 | - $name = sprintf($name[0], $name[2]); |
|
| 2093 | - else |
|
| 2094 | - $name = $name[0]; |
|
| 2145 | + if ( count($name) == 3 ) { |
|
| 2146 | + $name = sprintf($name[0], $name[2]); |
|
| 2147 | + } else { |
|
| 2148 | + $name = $name[0]; |
|
| 2149 | + } |
|
| 2095 | 2150 | } |
| 2096 | 2151 | |
| 2097 | 2152 | $id = sanitize_title($name); |
| 2098 | 2153 | $options = array(); |
| 2099 | - if ( !empty($classname) && is_string($classname) ) |
|
| 2100 | - $options['classname'] = $classname; |
|
| 2154 | + if ( !empty($classname) && is_string($classname) ) { |
|
| 2155 | + $options['classname'] = $classname; |
|
| 2156 | + } |
|
| 2101 | 2157 | $params = array_slice(func_get_args(), 2); |
| 2102 | 2158 | $args = array($id, $name, $output_callback, $options); |
| 2103 | - if ( !empty($params) ) |
|
| 2104 | - $args = array_merge($args, $params); |
|
| 2159 | + if ( !empty($params) ) { |
|
| 2160 | + $args = array_merge($args, $params); |
|
| 2161 | + } |
|
| 2105 | 2162 | |
| 2106 | 2163 | call_user_func_array('wp_register_sidebar_widget', $args); |
| 2107 | 2164 | } |
@@ -2143,22 +2200,26 @@ discard block |
||
| 2143 | 2200 | _deprecated_function( __FUNCTION__, '2.8', 'wp_register_widget_control()' ); |
| 2144 | 2201 | // Compat |
| 2145 | 2202 | if ( is_array($name) ) { |
| 2146 | - if ( count($name) == 3 ) |
|
| 2147 | - $name = sprintf($name[0], $name[2]); |
|
| 2148 | - else |
|
| 2149 | - $name = $name[0]; |
|
| 2203 | + if ( count($name) == 3 ) { |
|
| 2204 | + $name = sprintf($name[0], $name[2]); |
|
| 2205 | + } else { |
|
| 2206 | + $name = $name[0]; |
|
| 2207 | + } |
|
| 2150 | 2208 | } |
| 2151 | 2209 | |
| 2152 | 2210 | $id = sanitize_title($name); |
| 2153 | 2211 | $options = array(); |
| 2154 | - if ( !empty($width) ) |
|
| 2155 | - $options['width'] = $width; |
|
| 2156 | - if ( !empty($height) ) |
|
| 2157 | - $options['height'] = $height; |
|
| 2212 | + if ( !empty($width) ) { |
|
| 2213 | + $options['width'] = $width; |
|
| 2214 | + } |
|
| 2215 | + if ( !empty($height) ) { |
|
| 2216 | + $options['height'] = $height; |
|
| 2217 | + } |
|
| 2158 | 2218 | $params = array_slice(func_get_args(), 4); |
| 2159 | 2219 | $args = array($id, $name, $control_callback, $options); |
| 2160 | - if ( !empty($params) ) |
|
| 2161 | - $args = array_merge($args, $params); |
|
| 2220 | + if ( !empty($params) ) { |
|
| 2221 | + $args = array_merge($args, $params); |
|
| 2222 | + } |
|
| 2162 | 2223 | |
| 2163 | 2224 | call_user_func_array('wp_register_widget_control', $args); |
| 2164 | 2225 | } |
@@ -2192,29 +2253,34 @@ discard block |
||
| 2192 | 2253 | function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { |
| 2193 | 2254 | _deprecated_function( __FUNCTION__, '3.0', 'delete_user_meta()' ); |
| 2194 | 2255 | global $wpdb; |
| 2195 | - if ( !is_numeric( $user_id ) ) |
|
| 2196 | - return false; |
|
| 2256 | + if ( !is_numeric( $user_id ) ) { |
|
| 2257 | + return false; |
|
| 2258 | + } |
|
| 2197 | 2259 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2198 | 2260 | |
| 2199 | - if ( is_array($meta_value) || is_object($meta_value) ) |
|
| 2200 | - $meta_value = serialize($meta_value); |
|
| 2261 | + if ( is_array($meta_value) || is_object($meta_value) ) { |
|
| 2262 | + $meta_value = serialize($meta_value); |
|
| 2263 | + } |
|
| 2201 | 2264 | $meta_value = trim( $meta_value ); |
| 2202 | 2265 | |
| 2203 | 2266 | $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
| 2204 | 2267 | |
| 2205 | - if ( $cur && $cur->umeta_id ) |
|
| 2206 | - do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2268 | + if ( $cur && $cur->umeta_id ) { |
|
| 2269 | + do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2270 | + } |
|
| 2207 | 2271 | |
| 2208 | - if ( ! empty($meta_value) ) |
|
| 2209 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
| 2210 | - else |
|
| 2211 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2272 | + if ( ! empty($meta_value) ) { |
|
| 2273 | + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); |
|
| 2274 | + } else { |
|
| 2275 | + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2276 | + } |
|
| 2212 | 2277 | |
| 2213 | 2278 | clean_user_cache( $user_id ); |
| 2214 | 2279 | wp_cache_delete( $user_id, 'user_meta' ); |
| 2215 | 2280 | |
| 2216 | - if ( $cur && $cur->umeta_id ) |
|
| 2217 | - do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2281 | + if ( $cur && $cur->umeta_id ) { |
|
| 2282 | + do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2283 | + } |
|
| 2218 | 2284 | |
| 2219 | 2285 | return true; |
| 2220 | 2286 | } |
@@ -2240,35 +2306,39 @@ discard block |
||
| 2240 | 2306 | global $wpdb; |
| 2241 | 2307 | $user_id = (int) $user_id; |
| 2242 | 2308 | |
| 2243 | - if ( !$user_id ) |
|
| 2244 | - return false; |
|
| 2309 | + if ( !$user_id ) { |
|
| 2310 | + return false; |
|
| 2311 | + } |
|
| 2245 | 2312 | |
| 2246 | 2313 | if ( !empty($meta_key) ) { |
| 2247 | 2314 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2248 | 2315 | $user = wp_cache_get($user_id, 'users'); |
| 2249 | 2316 | // Check the cached user object |
| 2250 | - if ( false !== $user && isset($user->$meta_key) ) |
|
| 2251 | - $metas = array($user->$meta_key); |
|
| 2252 | - else |
|
| 2253 | - $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2317 | + if ( false !== $user && isset($user->$meta_key) ) { |
|
| 2318 | + $metas = array($user->$meta_key); |
|
| 2319 | + } else { |
|
| 2320 | + $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
|
| 2321 | + } |
|
| 2254 | 2322 | } else { |
| 2255 | 2323 | $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) ); |
| 2256 | 2324 | } |
| 2257 | 2325 | |
| 2258 | 2326 | if ( empty($metas) ) { |
| 2259 | - if ( empty($meta_key) ) |
|
| 2260 | - return array(); |
|
| 2261 | - else |
|
| 2262 | - return ''; |
|
| 2327 | + if ( empty($meta_key) ) { |
|
| 2328 | + return array(); |
|
| 2329 | + } else { |
|
| 2330 | + return ''; |
|
| 2331 | + } |
|
| 2263 | 2332 | } |
| 2264 | 2333 | |
| 2265 | 2334 | $metas = array_map('maybe_unserialize', $metas); |
| 2266 | 2335 | |
| 2267 | - if ( count($metas) == 1 ) |
|
| 2268 | - return $metas[0]; |
|
| 2269 | - else |
|
| 2270 | - return $metas; |
|
| 2271 | -} |
|
| 2336 | + if ( count($metas) == 1 ) { |
|
| 2337 | + return $metas[0]; |
|
| 2338 | + } else { |
|
| 2339 | + return $metas; |
|
| 2340 | + } |
|
| 2341 | + } |
|
| 2272 | 2342 | |
| 2273 | 2343 | /** |
| 2274 | 2344 | * Update metadata of user. |
@@ -2291,13 +2361,15 @@ discard block |
||
| 2291 | 2361 | function update_usermeta( $user_id, $meta_key, $meta_value ) { |
| 2292 | 2362 | _deprecated_function( __FUNCTION__, '3.0', 'update_user_meta()' ); |
| 2293 | 2363 | global $wpdb; |
| 2294 | - if ( !is_numeric( $user_id ) ) |
|
| 2295 | - return false; |
|
| 2364 | + if ( !is_numeric( $user_id ) ) { |
|
| 2365 | + return false; |
|
| 2366 | + } |
|
| 2296 | 2367 | $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); |
| 2297 | 2368 | |
| 2298 | 2369 | /** @todo Might need fix because usermeta data is assumed to be already escaped */ |
| 2299 | - if ( is_string($meta_value) ) |
|
| 2300 | - $meta_value = stripslashes($meta_value); |
|
| 2370 | + if ( is_string($meta_value) ) { |
|
| 2371 | + $meta_value = stripslashes($meta_value); |
|
| 2372 | + } |
|
| 2301 | 2373 | $meta_value = maybe_serialize($meta_value); |
| 2302 | 2374 | |
| 2303 | 2375 | if (empty($meta_value)) { |
@@ -2306,23 +2378,26 @@ discard block |
||
| 2306 | 2378 | |
| 2307 | 2379 | $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); |
| 2308 | 2380 | |
| 2309 | - if ( $cur ) |
|
| 2310 | - do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2381 | + if ( $cur ) { |
|
| 2382 | + do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2383 | + } |
|
| 2311 | 2384 | |
| 2312 | - if ( !$cur ) |
|
| 2313 | - $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
| 2314 | - elseif ( $cur->meta_value != $meta_value ) |
|
| 2315 | - $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
| 2316 | - else |
|
| 2317 | - return false; |
|
| 2385 | + if ( !$cur ) { |
|
| 2386 | + $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); |
|
| 2387 | + } elseif ( $cur->meta_value != $meta_value ) { |
|
| 2388 | + $wpdb->update($wpdb->usermeta, compact('meta_value'), compact('user_id', 'meta_key') ); |
|
| 2389 | + } else { |
|
| 2390 | + return false; |
|
| 2391 | + } |
|
| 2318 | 2392 | |
| 2319 | 2393 | clean_user_cache( $user_id ); |
| 2320 | 2394 | wp_cache_delete( $user_id, 'user_meta' ); |
| 2321 | 2395 | |
| 2322 | - if ( !$cur ) |
|
| 2323 | - do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
| 2324 | - else |
|
| 2325 | - do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2396 | + if ( !$cur ) { |
|
| 2397 | + do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); |
|
| 2398 | + } else { |
|
| 2399 | + do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); |
|
| 2400 | + } |
|
| 2326 | 2401 | |
| 2327 | 2402 | return true; |
| 2328 | 2403 | } |
@@ -2347,8 +2422,9 @@ discard block |
||
| 2347 | 2422 | _deprecated_function( __FUNCTION__, '3.1', 'get_users()' ); |
| 2348 | 2423 | |
| 2349 | 2424 | global $wpdb, $blog_id; |
| 2350 | - if ( empty($id) ) |
|
| 2351 | - $id = (int) $blog_id; |
|
| 2425 | + if ( empty($id) ) { |
|
| 2426 | + $id = (int) $blog_id; |
|
| 2427 | + } |
|
| 2352 | 2428 | $blog_prefix = $wpdb->get_blog_prefix($id); |
| 2353 | 2429 | $users = $wpdb->get_results( "SELECT user_id, user_id AS ID, user_login, display_name, user_email, meta_value FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY {$wpdb->usermeta}.user_id" ); |
| 2354 | 2430 | return $users; |
@@ -2366,10 +2442,12 @@ discard block |
||
| 2366 | 2442 | function automatic_feed_links( $add = true ) { |
| 2367 | 2443 | _deprecated_function( __FUNCTION__, '3.0', "add_theme_support( 'automatic-feed-links' )" ); |
| 2368 | 2444 | |
| 2369 | - if ( $add ) |
|
| 2370 | - add_theme_support( 'automatic-feed-links' ); |
|
| 2371 | - else |
|
| 2372 | - remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ |
|
| 2445 | + if ( $add ) { |
|
| 2446 | + add_theme_support( 'automatic-feed-links' ); |
|
| 2447 | + } else { |
|
| 2448 | + remove_action( 'wp_head', 'feed_links_extra', 3 ); |
|
| 2449 | + } |
|
| 2450 | + // Just do this yourself in 3.0+ |
|
| 2373 | 2451 | } |
| 2374 | 2452 | |
| 2375 | 2453 | /** |
@@ -2433,10 +2511,11 @@ discard block |
||
| 2433 | 2511 | // Fixes for browsers' JavaScript bugs. |
| 2434 | 2512 | global $is_macIE, $is_winIE; |
| 2435 | 2513 | |
| 2436 | - if ( $is_winIE || $is_macIE ) |
|
| 2437 | - $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
| 2514 | + if ( $is_winIE || $is_macIE ) { |
|
| 2515 | + $text = preg_replace_callback("/\%u([0-9A-F]{4,4})/", |
|
| 2438 | 2516 | "funky_javascript_callback", |
| 2439 | 2517 | $text); |
| 2518 | + } |
|
| 2440 | 2519 | |
| 2441 | 2520 | return $text; |
| 2442 | 2521 | } |
@@ -2490,8 +2569,9 @@ discard block |
||
| 2490 | 2569 | |
| 2491 | 2570 | global $plugin_page; |
| 2492 | 2571 | |
| 2493 | - if ( isset($plugin_page) ) |
|
| 2494 | - return true; |
|
| 2572 | + if ( isset($plugin_page) ) { |
|
| 2573 | + return true; |
|
| 2574 | + } |
|
| 2495 | 2575 | |
| 2496 | 2576 | return false; |
| 2497 | 2577 | } |
@@ -2562,8 +2642,9 @@ discard block |
||
| 2562 | 2642 | $objects = array(); |
| 2563 | 2643 | |
| 2564 | 2644 | $ids = array_map('intval', $ids); |
| 2565 | - foreach ( $ids as $id ) |
|
| 2566 | - $objects[$id] = array(); |
|
| 2645 | + foreach ( $ids as $id ) { |
|
| 2646 | + $objects[$id] = array(); |
|
| 2647 | + } |
|
| 2567 | 2648 | |
| 2568 | 2649 | $metas = update_meta_cache('user', $ids); |
| 2569 | 2650 | |
@@ -2594,21 +2675,25 @@ discard block |
||
| 2594 | 2675 | _deprecated_function( __FUNCTION__, '3.3' ); |
| 2595 | 2676 | |
| 2596 | 2677 | if ( is_object($user) ) { |
| 2597 | - if ( !isset($user->ID) ) |
|
| 2598 | - $user->ID = 0; |
|
| 2678 | + if ( !isset($user->ID) ) { |
|
| 2679 | + $user->ID = 0; |
|
| 2680 | + } |
|
| 2599 | 2681 | if ( ! ( $user instanceof WP_User ) ) { |
| 2600 | 2682 | $vars = get_object_vars($user); |
| 2601 | 2683 | foreach ( array_keys($vars) as $field ) { |
| 2602 | - if ( is_string($user->$field) || is_numeric($user->$field) ) |
|
| 2603 | - $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
|
| 2684 | + if ( is_string($user->$field) || is_numeric($user->$field) ) { |
|
| 2685 | + $user->$field = sanitize_user_field($field, $user->$field, $user->ID, $context); |
|
| 2686 | + } |
|
| 2604 | 2687 | } |
| 2605 | 2688 | } |
| 2606 | 2689 | $user->filter = $context; |
| 2607 | 2690 | } else { |
| 2608 | - if ( !isset($user['ID']) ) |
|
| 2609 | - $user['ID'] = 0; |
|
| 2610 | - foreach ( array_keys($user) as $field ) |
|
| 2611 | - $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
|
| 2691 | + if ( !isset($user['ID']) ) { |
|
| 2692 | + $user['ID'] = 0; |
|
| 2693 | + } |
|
| 2694 | + foreach ( array_keys($user) as $field ) { |
|
| 2695 | + $user[$field] = sanitize_user_field($field, $user[$field], $user['ID'], $context); |
|
| 2696 | + } |
|
| 2612 | 2697 | $user['filter'] = $context; |
| 2613 | 2698 | } |
| 2614 | 2699 | |
@@ -2634,14 +2719,16 @@ discard block |
||
| 2634 | 2719 | |
| 2635 | 2720 | $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); |
| 2636 | 2721 | // If there is no post stop. |
| 2637 | - if ( empty($posts) ) |
|
| 2638 | - return; |
|
| 2722 | + if ( empty($posts) ) { |
|
| 2723 | + return; |
|
| 2724 | + } |
|
| 2639 | 2725 | |
| 2640 | 2726 | // Even though we limited get_posts to return only 1 item it still returns an array of objects. |
| 2641 | 2727 | $post = $posts[0]; |
| 2642 | 2728 | |
| 2643 | - if ( empty($post->post_title) ) |
|
| 2644 | - $post->post_title = $start ? __('First Post') : __('Last Post'); |
|
| 2729 | + if ( empty($post->post_title) ) { |
|
| 2730 | + $post->post_title = $start ? __('First Post') : __('Last Post'); |
|
| 2731 | + } |
|
| 2645 | 2732 | |
| 2646 | 2733 | $date = mysql2date(get_option('date_format'), $post->post_date); |
| 2647 | 2734 | |
@@ -2712,11 +2799,13 @@ discard block |
||
| 2712 | 2799 | function get_parent_post_rel_link($title = '%title') { |
| 2713 | 2800 | _deprecated_function( __FUNCTION__, '3.3' ); |
| 2714 | 2801 | |
| 2715 | - if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) |
|
| 2716 | - $post = get_post($GLOBALS['post']->post_parent); |
|
| 2802 | + if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) { |
|
| 2803 | + $post = get_post($GLOBALS['post']->post_parent); |
|
| 2804 | + } |
|
| 2717 | 2805 | |
| 2718 | - if ( empty($post) ) |
|
| 2719 | - return; |
|
| 2806 | + if ( empty($post) ) { |
|
| 2807 | + return; |
|
| 2808 | + } |
|
| 2720 | 2809 | |
| 2721 | 2810 | $date = mysql2date(get_option('date_format'), $post->post_date); |
| 2722 | 2811 | |
@@ -2755,12 +2844,13 @@ discard block |
||
| 2755 | 2844 | $user_id = get_current_user_id(); |
| 2756 | 2845 | |
| 2757 | 2846 | if ( 0 != $user_id ) { |
| 2758 | - if ( is_admin() ) |
|
| 2759 | - $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
| 2760 | - elseif ( is_multisite() ) |
|
| 2761 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
| 2762 | - else |
|
| 2763 | - $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
| 2847 | + if ( is_admin() ) { |
|
| 2848 | + $wp_admin_bar->add_menu( array( 'id' => 'view-site', 'title' => __( 'Visit Site' ), 'href' => home_url() ) ); |
|
| 2849 | + } elseif ( is_multisite() ) { |
|
| 2850 | + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => get_dashboard_url( $user_id ) ) ); |
|
| 2851 | + } else { |
|
| 2852 | + $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'title' => __( 'Dashboard' ), 'href' => admin_url() ) ); |
|
| 2853 | + } |
|
| 2764 | 2854 | } |
| 2765 | 2855 | } |
| 2766 | 2856 | |
@@ -2805,9 +2895,10 @@ discard block |
||
| 2805 | 2895 | */ |
| 2806 | 2896 | function debug_fwrite( $fp, $string ) { |
| 2807 | 2897 | _deprecated_function( __FUNCTION__, 'error_log()' ); |
| 2808 | - if ( ! empty( $GLOBALS['debug'] ) ) |
|
| 2809 | - error_log( $string ); |
|
| 2810 | -} |
|
| 2898 | + if ( ! empty( $GLOBALS['debug'] ) ) { |
|
| 2899 | + error_log( $string ); |
|
| 2900 | + } |
|
| 2901 | + } |
|
| 2811 | 2902 | |
| 2812 | 2903 | /** |
| 2813 | 2904 | * Close the debugging file handle. |
@@ -2839,18 +2930,20 @@ discard block |
||
| 2839 | 2930 | _deprecated_function( __FUNCTION__, '3.4', 'wp_get_themes()' ); |
| 2840 | 2931 | |
| 2841 | 2932 | global $wp_themes; |
| 2842 | - if ( isset( $wp_themes ) ) |
|
| 2843 | - return $wp_themes; |
|
| 2933 | + if ( isset( $wp_themes ) ) { |
|
| 2934 | + return $wp_themes; |
|
| 2935 | + } |
|
| 2844 | 2936 | |
| 2845 | 2937 | $themes = wp_get_themes(); |
| 2846 | 2938 | $wp_themes = array(); |
| 2847 | 2939 | |
| 2848 | 2940 | foreach ( $themes as $theme ) { |
| 2849 | 2941 | $name = $theme->get('Name'); |
| 2850 | - if ( isset( $wp_themes[ $name ] ) ) |
|
| 2851 | - $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
| 2852 | - else |
|
| 2853 | - $wp_themes[ $name ] = $theme; |
|
| 2942 | + if ( isset( $wp_themes[ $name ] ) ) { |
|
| 2943 | + $wp_themes[ $name . '/' . $theme->get_stylesheet() ] = $theme; |
|
| 2944 | + } else { |
|
| 2945 | + $wp_themes[ $name ] = $theme; |
|
| 2946 | + } |
|
| 2854 | 2947 | } |
| 2855 | 2948 | |
| 2856 | 2949 | return $wp_themes; |
@@ -2870,8 +2963,9 @@ discard block |
||
| 2870 | 2963 | _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme( $stylesheet )' ); |
| 2871 | 2964 | |
| 2872 | 2965 | $themes = get_themes(); |
| 2873 | - if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) |
|
| 2874 | - return $themes[ $theme ]; |
|
| 2966 | + if ( is_array( $themes ) && array_key_exists( $theme, $themes ) ) { |
|
| 2967 | + return $themes[ $theme ]; |
|
| 2968 | + } |
|
| 2875 | 2969 | return null; |
| 2876 | 2970 | } |
| 2877 | 2971 | |
@@ -2887,8 +2981,9 @@ discard block |
||
| 2887 | 2981 | function get_current_theme() { |
| 2888 | 2982 | _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' ); |
| 2889 | 2983 | |
| 2890 | - if ( $theme = get_option( 'current_theme' ) ) |
|
| 2891 | - return $theme; |
|
| 2984 | + if ( $theme = get_option( 'current_theme' ) ) { |
|
| 2985 | + return $theme; |
|
| 2986 | + } |
|
| 2892 | 2987 | |
| 2893 | 2988 | return wp_get_theme()->get('Name'); |
| 2894 | 2989 | } |
@@ -2908,10 +3003,11 @@ discard block |
||
| 2908 | 3003 | function clean_pre($matches) { |
| 2909 | 3004 | _deprecated_function( __FUNCTION__, '3.4' ); |
| 2910 | 3005 | |
| 2911 | - if ( is_array($matches) ) |
|
| 2912 | - $text = $matches[1] . $matches[2] . "</pre>"; |
|
| 2913 | - else |
|
| 2914 | - $text = $matches; |
|
| 3006 | + if ( is_array($matches) ) { |
|
| 3007 | + $text = $matches[1] . $matches[2] . "</pre>"; |
|
| 3008 | + } else { |
|
| 3009 | + $text = $matches; |
|
| 3010 | + } |
|
| 2915 | 3011 | |
| 2916 | 3012 | $text = str_replace(array('<br />', '<br/>', '<br>'), array('', '', ''), $text); |
| 2917 | 3013 | $text = str_replace('<p>', "\n", $text); |
@@ -2938,8 +3034,9 @@ discard block |
||
| 2938 | 3034 | 'wp-head-callback' => $wp_head_callback, |
| 2939 | 3035 | 'admin-head-callback' => $admin_head_callback, |
| 2940 | 3036 | ); |
| 2941 | - if ( $admin_preview_callback ) |
|
| 2942 | - $args['admin-preview-callback'] = $admin_preview_callback; |
|
| 3037 | + if ( $admin_preview_callback ) { |
|
| 3038 | + $args['admin-preview-callback'] = $admin_preview_callback; |
|
| 3039 | + } |
|
| 2943 | 3040 | return add_theme_support( 'custom-header', $args ); |
| 2944 | 3041 | } |
| 2945 | 3042 | |
@@ -2971,12 +3068,15 @@ discard block |
||
| 2971 | 3068 | function add_custom_background( $wp_head_callback = '', $admin_head_callback = '', $admin_preview_callback = '' ) { |
| 2972 | 3069 | _deprecated_function( __FUNCTION__, '3.4', 'add_theme_support( \'custom-background\', $args )' ); |
| 2973 | 3070 | $args = array(); |
| 2974 | - if ( $wp_head_callback ) |
|
| 2975 | - $args['wp-head-callback'] = $wp_head_callback; |
|
| 2976 | - if ( $admin_head_callback ) |
|
| 2977 | - $args['admin-head-callback'] = $admin_head_callback; |
|
| 2978 | - if ( $admin_preview_callback ) |
|
| 2979 | - $args['admin-preview-callback'] = $admin_preview_callback; |
|
| 3071 | + if ( $wp_head_callback ) { |
|
| 3072 | + $args['wp-head-callback'] = $wp_head_callback; |
|
| 3073 | + } |
|
| 3074 | + if ( $admin_head_callback ) { |
|
| 3075 | + $args['admin-head-callback'] = $admin_head_callback; |
|
| 3076 | + } |
|
| 3077 | + if ( $admin_preview_callback ) { |
|
| 3078 | + $args['admin-preview-callback'] = $admin_preview_callback; |
|
| 3079 | + } |
|
| 2980 | 3080 | return add_theme_support( 'custom-background', $args ); |
| 2981 | 3081 | } |
| 2982 | 3082 | |
@@ -3023,8 +3123,9 @@ discard block |
||
| 3023 | 3123 | ); |
| 3024 | 3124 | |
| 3025 | 3125 | foreach ( apply_filters( 'extra_theme_headers', array() ) as $extra_header ) { |
| 3026 | - if ( ! isset( $theme_data[ $extra_header ] ) ) |
|
| 3027 | - $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
| 3126 | + if ( ! isset( $theme_data[ $extra_header ] ) ) { |
|
| 3127 | + $theme_data[ $extra_header ] = $theme->get( $extra_header ); |
|
| 3128 | + } |
|
| 3028 | 3129 | } |
| 3029 | 3130 | |
| 3030 | 3131 | return $theme_data; |
@@ -3093,9 +3194,10 @@ discard block |
||
| 3093 | 3194 | */ |
| 3094 | 3195 | function sticky_class( $post_id = null ) { |
| 3095 | 3196 | _deprecated_function( __FUNCTION__, '3.5', 'post_class()' ); |
| 3096 | - if ( is_sticky( $post_id ) ) |
|
| 3097 | - echo ' sticky'; |
|
| 3098 | -} |
|
| 3197 | + if ( is_sticky( $post_id ) ) { |
|
| 3198 | + echo ' sticky'; |
|
| 3199 | + } |
|
| 3200 | + } |
|
| 3099 | 3201 | |
| 3100 | 3202 | /** |
| 3101 | 3203 | * Retrieve post ancestors. |
@@ -3124,21 +3226,25 @@ discard block |
||
| 3124 | 3226 | function wp_load_image( $file ) { |
| 3125 | 3227 | _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); |
| 3126 | 3228 | |
| 3127 | - if ( is_numeric( $file ) ) |
|
| 3128 | - $file = get_attached_file( $file ); |
|
| 3229 | + if ( is_numeric( $file ) ) { |
|
| 3230 | + $file = get_attached_file( $file ); |
|
| 3231 | + } |
|
| 3129 | 3232 | |
| 3130 | - if ( ! is_file( $file ) ) |
|
| 3131 | - return sprintf(__('File “%s” doesn’t exist?'), $file); |
|
| 3233 | + if ( ! is_file( $file ) ) { |
|
| 3234 | + return sprintf(__('File “%s” doesn’t exist?'), $file); |
|
| 3235 | + } |
|
| 3132 | 3236 | |
| 3133 | - if ( ! function_exists('imagecreatefromstring') ) |
|
| 3134 | - return __('The GD image library is not installed.'); |
|
| 3237 | + if ( ! function_exists('imagecreatefromstring') ) { |
|
| 3238 | + return __('The GD image library is not installed.'); |
|
| 3239 | + } |
|
| 3135 | 3240 | |
| 3136 | 3241 | // Set artificially high because GD uses uncompressed images in memory |
| 3137 | 3242 | @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 3138 | 3243 | $image = imagecreatefromstring( file_get_contents( $file ) ); |
| 3139 | 3244 | |
| 3140 | - if ( !is_resource( $image ) ) |
|
| 3141 | - return sprintf(__('File “%s” is not an image.'), $file); |
|
| 3245 | + if ( !is_resource( $image ) ) { |
|
| 3246 | + return sprintf(__('File “%s” is not an image.'), $file); |
|
| 3247 | + } |
|
| 3142 | 3248 | |
| 3143 | 3249 | return $image; |
| 3144 | 3250 | } |
@@ -3171,19 +3277,22 @@ discard block |
||
| 3171 | 3277 | _deprecated_function( __FUNCTION__, '3.5', 'wp_get_image_editor()' ); |
| 3172 | 3278 | |
| 3173 | 3279 | $editor = wp_get_image_editor( $file ); |
| 3174 | - if ( is_wp_error( $editor ) ) |
|
| 3175 | - return $editor; |
|
| 3280 | + if ( is_wp_error( $editor ) ) { |
|
| 3281 | + return $editor; |
|
| 3282 | + } |
|
| 3176 | 3283 | $editor->set_quality( $jpeg_quality ); |
| 3177 | 3284 | |
| 3178 | 3285 | $resized = $editor->resize( $max_w, $max_h, $crop ); |
| 3179 | - if ( is_wp_error( $resized ) ) |
|
| 3180 | - return $resized; |
|
| 3286 | + if ( is_wp_error( $resized ) ) { |
|
| 3287 | + return $resized; |
|
| 3288 | + } |
|
| 3181 | 3289 | |
| 3182 | 3290 | $dest_file = $editor->generate_filename( $suffix, $dest_path ); |
| 3183 | 3291 | $saved = $editor->save( $dest_file ); |
| 3184 | 3292 | |
| 3185 | - if ( is_wp_error( $saved ) ) |
|
| 3186 | - return $saved; |
|
| 3293 | + if ( is_wp_error( $saved ) ) { |
|
| 3294 | + return $saved; |
|
| 3295 | + } |
|
| 3187 | 3296 | |
| 3188 | 3297 | return $dest_file; |
| 3189 | 3298 | } |
@@ -3221,8 +3330,9 @@ discard block |
||
| 3221 | 3330 | function user_pass_ok($user_login, $user_pass) { |
| 3222 | 3331 | _deprecated_function( __FUNCTION__, '3.5', 'wp_authenticate()' ); |
| 3223 | 3332 | $user = wp_authenticate( $user_login, $user_pass ); |
| 3224 | - if ( is_wp_error( $user ) ) |
|
| 3225 | - return false; |
|
| 3333 | + if ( is_wp_error( $user ) ) { |
|
| 3334 | + return false; |
|
| 3335 | + } |
|
| 3226 | 3336 | |
| 3227 | 3337 | return true; |
| 3228 | 3338 | } |
@@ -3325,8 +3435,9 @@ discard block |
||
| 3325 | 3435 | global $wp_rich_edit_exists; |
| 3326 | 3436 | _deprecated_function( __FUNCTION__, '3.9' ); |
| 3327 | 3437 | |
| 3328 | - if ( ! isset( $wp_rich_edit_exists ) ) |
|
| 3329 | - $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
| 3438 | + if ( ! isset( $wp_rich_edit_exists ) ) { |
|
| 3439 | + $wp_rich_edit_exists = file_exists( ABSPATH . WPINC . '/js/tinymce/tinymce.js' ); |
|
| 3440 | + } |
|
| 3330 | 3441 | |
| 3331 | 3442 | return $wp_rich_edit_exists; |
| 3332 | 3443 | } |
@@ -3531,8 +3642,10 @@ discard block |
||
| 3531 | 3642 | function wp_htmledit_pre($output) { |
| 3532 | 3643 | _deprecated_function( __FUNCTION__, '4.3', 'format_for_editor()' ); |
| 3533 | 3644 | |
| 3534 | - if ( !empty($output) ) |
|
| 3535 | - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & |
|
| 3645 | + if ( !empty($output) ) { |
|
| 3646 | + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
|
| 3647 | + } |
|
| 3648 | + // convert only < > & |
|
| 3536 | 3649 | |
| 3537 | 3650 | /** |
| 3538 | 3651 | * Filter the text before it is formatted for the HTML editor. |
@@ -524,7 +524,7 @@ |
||
| 524 | 524 | * @since 2.5.0 |
| 525 | 525 | * |
| 526 | 526 | * @param string $data Input string |
| 527 | - * @return array array(type, value) |
|
| 527 | + * @return string[] array(type, value) |
|
| 528 | 528 | */ |
| 529 | 529 | function prep_atom_text_construct($data) { |
| 530 | 530 | if (strpos($data, '<') === false && strpos($data, '&') === false) { |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * WordPress Feed API |
|
| 4 | - * |
|
| 5 | - * Many of the functions used in here belong in The Loop, or The Loop for the |
|
| 6 | - * Feeds. |
|
| 7 | - * |
|
| 8 | - * @package WordPress |
|
| 9 | - * @subpackage Feed |
|
| 10 | - */ |
|
| 3 | + * WordPress Feed API |
|
| 4 | + * |
|
| 5 | + * Many of the functions used in here belong in The Loop, or The Loop for the |
|
| 6 | + * Feeds. |
|
| 7 | + * |
|
| 8 | + * @package WordPress |
|
| 9 | + * @subpackage Feed |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * RSS container for the bloginfo function. |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param string $info Converted string value of the blog information. |
| 36 | 36 | * @param string $show The type of blog information to retrieve. |
| 37 | 37 | */ |
| 38 | - return apply_filters( 'get_bloginfo_rss', convert_chars( $info ), $show ); |
|
| 38 | + return apply_filters('get_bloginfo_rss', convert_chars($info), $show); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param string $rss_container RSS container for the blog information. |
| 62 | 62 | * @param string $show The type of blog information to retrieve. |
| 63 | 63 | */ |
| 64 | - echo apply_filters( 'bloginfo_rss', get_bloginfo_rss( $show ), $show ); |
|
| 64 | + echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string $feed_type Type of default feed. Possible values include 'rss2', 'atom'. |
| 84 | 84 | * Default 'rss2'. |
| 85 | 85 | */ |
| 86 | - $default_feed = apply_filters( 'default_feed', 'rss2' ); |
|
| 86 | + $default_feed = apply_filters('default_feed', 'rss2'); |
|
| 87 | 87 | return 'rss' == $default_feed ? 'rss2' : $default_feed; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | * @param string $sep Optional. How to separate the title. See wp_title() for more info. |
| 96 | 96 | * @return string Error message on failure or blog title on success. |
| 97 | 97 | */ |
| 98 | -function get_wp_title_rss( $sep = '»' ) { |
|
| 99 | - $title = wp_title( $sep, false ); |
|
| 98 | +function get_wp_title_rss($sep = '»') { |
|
| 99 | + $title = wp_title($sep, false); |
|
| 100 | 100 | |
| 101 | - if ( is_wp_error( $title ) ) { |
|
| 101 | + if (is_wp_error($title)) { |
|
| 102 | 102 | return $title->get_error_message(); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $title && $sep && ' ' !== substr( $title, 0, 1 ) ) { |
|
| 106 | - $title = " $sep " . $title; |
|
| 105 | + if ($title && $sep && ' ' !== substr($title, 0, 1)) { |
|
| 106 | + $title = " $sep ".$title; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * @param string $title The current blog title. |
| 115 | 115 | * @param string $sep Separator used by wp_title(). |
| 116 | 116 | */ |
| 117 | - $title = apply_filters( 'get_wp_title_rss', $title, $sep ); |
|
| 117 | + $title = apply_filters('get_wp_title_rss', $title, $sep); |
|
| 118 | 118 | return $title; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @param string $sep Optional. |
| 128 | 128 | */ |
| 129 | -function wp_title_rss( $sep = '»' ) { |
|
| 129 | +function wp_title_rss($sep = '»') { |
|
| 130 | 130 | /** |
| 131 | 131 | * Filter the blog title for display of the feed title. |
| 132 | 132 | * |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string $wp_title The current blog title. |
| 138 | 138 | * @param string $sep Separator used by wp_title(). |
| 139 | 139 | */ |
| 140 | - echo apply_filters( 'wp_title_rss', get_wp_title_rss( $sep ), $sep ); |
|
| 140 | + echo apply_filters('wp_title_rss', get_wp_title_rss($sep), $sep); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @param string $title The current post title. |
| 158 | 158 | */ |
| 159 | - $title = apply_filters( 'the_title_rss', $title ); |
|
| 159 | + $title = apply_filters('the_title_rss', $title); |
|
| 160 | 160 | return $title; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | * @return string The filtered content. |
| 180 | 180 | */ |
| 181 | 181 | function get_the_content_feed($feed_type = null) { |
| 182 | - if ( !$feed_type ) |
|
| 182 | + if ( ! $feed_type) |
|
| 183 | 183 | $feed_type = get_default_feed(); |
| 184 | 184 | |
| 185 | 185 | /** This filter is documented in wp-includes/post-template.php */ |
| 186 | - $content = apply_filters( 'the_content', get_the_content() ); |
|
| 186 | + $content = apply_filters('the_content', get_the_content()); |
|
| 187 | 187 | $content = str_replace(']]>', ']]>', $content); |
| 188 | 188 | /** |
| 189 | 189 | * Filter the post content for use in feeds. |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'. |
| 195 | 195 | * Default 'rss2'. |
| 196 | 196 | */ |
| 197 | - return apply_filters( 'the_content_feed', $content, $feed_type ); |
|
| 197 | + return apply_filters('the_content_feed', $content, $feed_type); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param string $output The current post excerpt. |
| 224 | 224 | */ |
| 225 | - echo apply_filters( 'the_excerpt_rss', $output ); |
|
| 225 | + echo apply_filters('the_excerpt_rss', $output); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param string $post_permalink The current post permalink. |
| 240 | 240 | */ |
| 241 | - echo esc_url( apply_filters( 'the_permalink_rss', get_permalink() ) ); |
|
| 241 | + echo esc_url(apply_filters('the_permalink_rss', get_permalink())); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | * @param string $comment_permalink The current comment permalink with |
| 257 | 257 | * '#comments' appended. |
| 258 | 258 | */ |
| 259 | - echo esc_url( apply_filters( 'comments_link_feed', get_comments_link() ) ); |
|
| 259 | + echo esc_url(apply_filters('comments_link_feed', get_comments_link())); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @param int|object $comment_id Optional comment object or id. Defaults to global comment object. |
| 268 | 268 | */ |
| 269 | 269 | function comment_guid($comment_id = null) { |
| 270 | - echo esc_url( get_comment_guid($comment_id) ); |
|
| 270 | + echo esc_url(get_comment_guid($comment_id)); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | function get_comment_guid($comment_id = null) { |
| 282 | 282 | $comment = get_comment($comment_id); |
| 283 | 283 | |
| 284 | - if ( !is_object($comment) ) |
|
| 284 | + if ( ! is_object($comment)) |
|
| 285 | 285 | return false; |
| 286 | 286 | |
| 287 | - return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; |
|
| 287 | + return get_the_guid($comment->comment_post_ID).'#comment-'.$comment->comment_ID; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @param string $comment_permalink The current comment permalink. |
| 304 | 304 | */ |
| 305 | - echo esc_url( apply_filters( 'comment_link', get_comment_link() ) ); |
|
| 305 | + echo esc_url(apply_filters('comment_link', get_comment_link())); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * |
| 323 | 323 | * @param string $comment_author The current comment author. |
| 324 | 324 | */ |
| 325 | - return apply_filters( 'comment_author_rss', get_comment_author() ); |
|
| 325 | + return apply_filters('comment_author_rss', get_comment_author()); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @param string $comment_text The content of the current comment. |
| 350 | 350 | */ |
| 351 | - $comment_text = apply_filters( 'comment_text_rss', $comment_text ); |
|
| 351 | + $comment_text = apply_filters('comment_text_rss', $comment_text); |
|
| 352 | 352 | echo $comment_text; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @return string All of the post categories for displaying in the feed. |
| 366 | 366 | */ |
| 367 | 367 | function get_the_category_rss($type = null) { |
| 368 | - if ( empty($type) ) |
|
| 368 | + if (empty($type)) |
|
| 369 | 369 | $type = get_default_feed(); |
| 370 | 370 | $categories = get_the_category(); |
| 371 | 371 | $tags = get_the_tags(); |
@@ -373,26 +373,26 @@ discard block |
||
| 373 | 373 | $cat_names = array(); |
| 374 | 374 | |
| 375 | 375 | $filter = 'rss'; |
| 376 | - if ( 'atom' == $type ) |
|
| 376 | + if ('atom' == $type) |
|
| 377 | 377 | $filter = 'raw'; |
| 378 | 378 | |
| 379 | - if ( !empty($categories) ) foreach ( (array) $categories as $category ) { |
|
| 379 | + if ( ! empty($categories)) foreach ((array) $categories as $category) { |
|
| 380 | 380 | $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { |
|
| 383 | + if ( ! empty($tags)) foreach ((array) $tags as $tag) { |
|
| 384 | 384 | $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | $cat_names = array_unique($cat_names); |
| 388 | 388 | |
| 389 | - foreach ( $cat_names as $cat_name ) { |
|
| 390 | - if ( 'rdf' == $type ) |
|
| 389 | + foreach ($cat_names as $cat_name) { |
|
| 390 | + if ('rdf' == $type) |
|
| 391 | 391 | $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; |
| 392 | - elseif ( 'atom' == $type ) |
|
| 393 | - $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); |
|
| 392 | + elseif ('atom' == $type) |
|
| 393 | + $the_list .= sprintf('<category scheme="%1$s" term="%2$s" />', esc_attr(get_bloginfo_rss('url')), esc_attr($cat_name)); |
|
| 394 | 394 | else |
| 395 | - $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n"; |
|
| 395 | + $the_list .= "\t\t<category><![CDATA[".@html_entity_decode($cat_name, ENT_COMPAT, get_option('blog_charset'))."]]></category>\n"; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @param string $type Type of feed. Possible values include 'rss2', 'atom'. |
| 405 | 405 | * Default 'rss2'. |
| 406 | 406 | */ |
| 407 | - return apply_filters( 'the_category_rss', $the_list, $type ); |
|
| 407 | + return apply_filters('the_category_rss', $the_list, $type); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -450,16 +450,16 @@ discard block |
||
| 450 | 450 | * @since 1.5.0 |
| 451 | 451 | */ |
| 452 | 452 | function rss_enclosure() { |
| 453 | - if ( post_password_required() ) |
|
| 453 | + if (post_password_required()) |
|
| 454 | 454 | return; |
| 455 | 455 | |
| 456 | - foreach ( (array) get_post_custom() as $key => $val) { |
|
| 456 | + foreach ((array) get_post_custom() as $key => $val) { |
|
| 457 | 457 | if ($key == 'enclosure') { |
| 458 | - foreach ( (array) $val as $enc ) { |
|
| 458 | + foreach ((array) $val as $enc) { |
|
| 459 | 459 | $enclosure = explode("\n", $enc); |
| 460 | 460 | |
| 461 | 461 | // only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3' |
| 462 | - $t = preg_split('/[ \t]/', trim($enclosure[2]) ); |
|
| 462 | + $t = preg_split('/[ \t]/', trim($enclosure[2])); |
|
| 463 | 463 | $type = $t[0]; |
| 464 | 464 | |
| 465 | 465 | /** |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | * |
| 470 | 470 | * @param string $html_link_tag The HTML link tag with a URI and other attributes. |
| 471 | 471 | */ |
| 472 | - echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" ); |
|
| 472 | + echo apply_filters('rss_enclosure', '<enclosure url="'.trim(htmlspecialchars($enclosure[0])).'" length="'.trim($enclosure[1]).'" type="'.$type.'" />'."\n"); |
|
| 473 | 473 | } |
| 474 | 474 | } |
| 475 | 475 | } |
@@ -489,12 +489,12 @@ discard block |
||
| 489 | 489 | * @since 2.2.0 |
| 490 | 490 | */ |
| 491 | 491 | function atom_enclosure() { |
| 492 | - if ( post_password_required() ) |
|
| 492 | + if (post_password_required()) |
|
| 493 | 493 | return; |
| 494 | 494 | |
| 495 | - foreach ( (array) get_post_custom() as $key => $val ) { |
|
| 495 | + foreach ((array) get_post_custom() as $key => $val) { |
|
| 496 | 496 | if ($key == 'enclosure') { |
| 497 | - foreach ( (array) $val as $enc ) { |
|
| 497 | + foreach ((array) $val as $enc) { |
|
| 498 | 498 | $enclosure = explode("\n", $enc); |
| 499 | 499 | /** |
| 500 | 500 | * Filter the atom enclosure HTML link tag for the current post. |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | * |
| 504 | 504 | * @param string $html_link_tag The HTML link tag with a URI and other attributes. |
| 505 | 505 | */ |
| 506 | - echo apply_filters( 'atom_enclosure', '<link href="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" rel="enclosure" length="' . trim( $enclosure[1] ) . '" type="' . trim( $enclosure[2] ) . '" />' . "\n" ); |
|
| 506 | + echo apply_filters('atom_enclosure', '<link href="'.trim(htmlspecialchars($enclosure[0])).'" rel="enclosure" length="'.trim($enclosure[1]).'" type="'.trim($enclosure[2]).'" />'."\n"); |
|
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | } |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | $parser = xml_parser_create(); |
| 535 | - xml_parse($parser, '<div>' . $data . '</div>', true); |
|
| 535 | + xml_parse($parser, '<div>'.$data.'</div>', true); |
|
| 536 | 536 | $code = xml_get_error_code($parser); |
| 537 | 537 | xml_parser_free($parser); |
| 538 | 538 | |
| 539 | - if (!$code) { |
|
| 539 | + if ( ! $code) { |
|
| 540 | 540 | if (strpos($data, '<') === false) { |
| 541 | 541 | return array('text', $data); |
| 542 | 542 | } else { |
@@ -560,8 +560,8 @@ discard block |
||
| 560 | 560 | * @see get_site_icon_url() |
| 561 | 561 | */ |
| 562 | 562 | function atom_site_icon() { |
| 563 | - $url = get_site_icon_url( 32 ); |
|
| 564 | - if ( $url ) { |
|
| 563 | + $url = get_site_icon_url(32); |
|
| 564 | + if ($url) { |
|
| 565 | 565 | echo "<icon>$url</icon>\n"; |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -573,17 +573,17 @@ discard block |
||
| 573 | 573 | */ |
| 574 | 574 | function rss2_site_icon() { |
| 575 | 575 | $rss_title = get_wp_title_rss(); |
| 576 | - if ( empty( $rss_title ) ) { |
|
| 577 | - $rss_title = get_bloginfo_rss( 'name' ); |
|
| 576 | + if (empty($rss_title)) { |
|
| 577 | + $rss_title = get_bloginfo_rss('name'); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - $url = get_site_icon_url( 32 ); |
|
| 581 | - if ( $url ) { |
|
| 580 | + $url = get_site_icon_url(32); |
|
| 581 | + if ($url) { |
|
| 582 | 582 | echo ' |
| 583 | 583 | <image> |
| 584 | - <url>' . convert_chars( $url ) . '</url> |
|
| 585 | - <title>' . $rss_title . '</title> |
|
| 586 | - <link>' . get_bloginfo_rss( 'url' ) . '</link> |
|
| 584 | + <url>' . convert_chars($url).'</url> |
|
| 585 | + <title>' . $rss_title.'</title> |
|
| 586 | + <link>' . get_bloginfo_rss('url').'</link> |
|
| 587 | 587 | <width>32</width> |
| 588 | 588 | <height>32</height> |
| 589 | 589 | </image> ' . "\n"; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | * |
| 610 | 610 | * @param string $feed_link The link for the feed with set URL scheme. |
| 611 | 611 | */ |
| 612 | - echo esc_url( apply_filters( 'self_link', set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
|
| 612 | + echo esc_url(apply_filters('self_link', set_url_scheme('http://'.$host['host'].wp_unslash($_SERVER['REQUEST_URI'])))); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -617,8 +617,8 @@ discard block |
||
| 617 | 617 | * |
| 618 | 618 | * @since 2.8.0 |
| 619 | 619 | */ |
| 620 | -function feed_content_type( $type = '' ) { |
|
| 621 | - if ( empty($type) ) |
|
| 620 | +function feed_content_type($type = '') { |
|
| 621 | + if (empty($type)) |
|
| 622 | 622 | $type = get_default_feed(); |
| 623 | 623 | |
| 624 | 624 | $types = array( |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | 'rdf' => 'application/rdf+xml' |
| 630 | 630 | ); |
| 631 | 631 | |
| 632 | - $content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream'; |
|
| 632 | + $content_type = ( ! empty($types[$type])) ? $types[$type] : 'application/octet-stream'; |
|
| 633 | 633 | |
| 634 | 634 | /** |
| 635 | 635 | * Filter the content type for a specific feed type. |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | * @param string $type Type of feed. Possible values include 'rss2', 'atom'. |
| 641 | 641 | * Default 'rss2'. |
| 642 | 642 | */ |
| 643 | - return apply_filters( 'feed_content_type', $content_type, $type ); |
|
| 643 | + return apply_filters('feed_content_type', $content_type, $type); |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | /** |
@@ -654,22 +654,22 @@ discard block |
||
| 654 | 654 | * |
| 655 | 655 | * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success |
| 656 | 656 | */ |
| 657 | -function fetch_feed( $url ) { |
|
| 658 | - require_once( ABSPATH . WPINC . '/class-feed.php' ); |
|
| 657 | +function fetch_feed($url) { |
|
| 658 | + require_once(ABSPATH.WPINC.'/class-feed.php'); |
|
| 659 | 659 | |
| 660 | 660 | $feed = new SimplePie(); |
| 661 | 661 | |
| 662 | - $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); |
|
| 662 | + $feed->set_sanitize_class('WP_SimplePie_Sanitize_KSES'); |
|
| 663 | 663 | // We must manually overwrite $feed->sanitize because SimplePie's |
| 664 | 664 | // constructor sets it before we have a chance to set the sanitization class |
| 665 | 665 | $feed->sanitize = new WP_SimplePie_Sanitize_KSES(); |
| 666 | 666 | |
| 667 | - $feed->set_cache_class( 'WP_Feed_Cache' ); |
|
| 668 | - $feed->set_file_class( 'WP_SimplePie_File' ); |
|
| 667 | + $feed->set_cache_class('WP_Feed_Cache'); |
|
| 668 | + $feed->set_file_class('WP_SimplePie_File'); |
|
| 669 | 669 | |
| 670 | - $feed->set_feed_url( $url ); |
|
| 670 | + $feed->set_feed_url($url); |
|
| 671 | 671 | /** This filter is documented in wp-includes/class-feed.php */ |
| 672 | - $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) ); |
|
| 672 | + $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url)); |
|
| 673 | 673 | /** |
| 674 | 674 | * Fires just before processing the SimplePie feed object. |
| 675 | 675 | * |
@@ -678,13 +678,13 @@ discard block |
||
| 678 | 678 | * @param object &$feed SimplePie feed object, passed by reference. |
| 679 | 679 | * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged. |
| 680 | 680 | */ |
| 681 | - do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); |
|
| 681 | + do_action_ref_array('wp_feed_options', array(&$feed, $url)); |
|
| 682 | 682 | $feed->init(); |
| 683 | - $feed->set_output_encoding( get_option( 'blog_charset' ) ); |
|
| 683 | + $feed->set_output_encoding(get_option('blog_charset')); |
|
| 684 | 684 | $feed->handle_content_type(); |
| 685 | 685 | |
| 686 | - if ( $feed->error() ) |
|
| 687 | - return new WP_Error( 'simplepie-error', $feed->error() ); |
|
| 686 | + if ($feed->error()) |
|
| 687 | + return new WP_Error('simplepie-error', $feed->error()); |
|
| 688 | 688 | |
| 689 | 689 | return $feed; |
| 690 | 690 | } |
@@ -179,8 +179,9 @@ discard block |
||
| 179 | 179 | * @return string The filtered content. |
| 180 | 180 | */ |
| 181 | 181 | function get_the_content_feed($feed_type = null) { |
| 182 | - if ( !$feed_type ) |
|
| 183 | - $feed_type = get_default_feed(); |
|
| 182 | + if ( !$feed_type ) { |
|
| 183 | + $feed_type = get_default_feed(); |
|
| 184 | + } |
|
| 184 | 185 | |
| 185 | 186 | /** This filter is documented in wp-includes/post-template.php */ |
| 186 | 187 | $content = apply_filters( 'the_content', get_the_content() ); |
@@ -281,8 +282,9 @@ discard block |
||
| 281 | 282 | function get_comment_guid($comment_id = null) { |
| 282 | 283 | $comment = get_comment($comment_id); |
| 283 | 284 | |
| 284 | - if ( !is_object($comment) ) |
|
| 285 | - return false; |
|
| 285 | + if ( !is_object($comment) ) { |
|
| 286 | + return false; |
|
| 287 | + } |
|
| 286 | 288 | |
| 287 | 289 | return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID; |
| 288 | 290 | } |
@@ -365,34 +367,41 @@ discard block |
||
| 365 | 367 | * @return string All of the post categories for displaying in the feed. |
| 366 | 368 | */ |
| 367 | 369 | function get_the_category_rss($type = null) { |
| 368 | - if ( empty($type) ) |
|
| 369 | - $type = get_default_feed(); |
|
| 370 | + if ( empty($type) ) { |
|
| 371 | + $type = get_default_feed(); |
|
| 372 | + } |
|
| 370 | 373 | $categories = get_the_category(); |
| 371 | 374 | $tags = get_the_tags(); |
| 372 | 375 | $the_list = ''; |
| 373 | 376 | $cat_names = array(); |
| 374 | 377 | |
| 375 | 378 | $filter = 'rss'; |
| 376 | - if ( 'atom' == $type ) |
|
| 377 | - $filter = 'raw'; |
|
| 379 | + if ( 'atom' == $type ) { |
|
| 380 | + $filter = 'raw'; |
|
| 381 | + } |
|
| 378 | 382 | |
| 379 | - if ( !empty($categories) ) foreach ( (array) $categories as $category ) { |
|
| 383 | + if ( !empty($categories) ) { |
|
| 384 | + foreach ( (array) $categories as $category ) { |
|
| 380 | 385 | $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter); |
| 381 | 386 | } |
| 387 | + } |
|
| 382 | 388 | |
| 383 | - if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { |
|
| 389 | + if ( !empty($tags) ) { |
|
| 390 | + foreach ( (array) $tags as $tag ) { |
|
| 384 | 391 | $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter); |
| 385 | 392 | } |
| 393 | + } |
|
| 386 | 394 | |
| 387 | 395 | $cat_names = array_unique($cat_names); |
| 388 | 396 | |
| 389 | 397 | foreach ( $cat_names as $cat_name ) { |
| 390 | - if ( 'rdf' == $type ) |
|
| 391 | - $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; |
|
| 392 | - elseif ( 'atom' == $type ) |
|
| 393 | - $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); |
|
| 394 | - else |
|
| 395 | - $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n"; |
|
| 398 | + if ( 'rdf' == $type ) { |
|
| 399 | + $the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n"; |
|
| 400 | + } elseif ( 'atom' == $type ) { |
|
| 401 | + $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); |
|
| 402 | + } else { |
|
| 403 | + $the_list .= "\t\t<category><![CDATA[" . @html_entity_decode( $cat_name, ENT_COMPAT, get_option('blog_charset') ) . "]]></category>\n"; |
|
| 404 | + } |
|
| 396 | 405 | } |
| 397 | 406 | |
| 398 | 407 | /** |
@@ -428,10 +437,11 @@ discard block |
||
| 428 | 437 | */ |
| 429 | 438 | function html_type_rss() { |
| 430 | 439 | $type = get_bloginfo('html_type'); |
| 431 | - if (strpos($type, 'xhtml') !== false) |
|
| 432 | - $type = 'xhtml'; |
|
| 433 | - else |
|
| 434 | - $type = 'html'; |
|
| 440 | + if (strpos($type, 'xhtml') !== false) { |
|
| 441 | + $type = 'xhtml'; |
|
| 442 | + } else { |
|
| 443 | + $type = 'html'; |
|
| 444 | + } |
|
| 435 | 445 | echo $type; |
| 436 | 446 | } |
| 437 | 447 | |
@@ -450,8 +460,9 @@ discard block |
||
| 450 | 460 | * @since 1.5.0 |
| 451 | 461 | */ |
| 452 | 462 | function rss_enclosure() { |
| 453 | - if ( post_password_required() ) |
|
| 454 | - return; |
|
| 463 | + if ( post_password_required() ) { |
|
| 464 | + return; |
|
| 465 | + } |
|
| 455 | 466 | |
| 456 | 467 | foreach ( (array) get_post_custom() as $key => $val) { |
| 457 | 468 | if ($key == 'enclosure') { |
@@ -489,8 +500,9 @@ discard block |
||
| 489 | 500 | * @since 2.2.0 |
| 490 | 501 | */ |
| 491 | 502 | function atom_enclosure() { |
| 492 | - if ( post_password_required() ) |
|
| 493 | - return; |
|
| 503 | + if ( post_password_required() ) { |
|
| 504 | + return; |
|
| 505 | + } |
|
| 494 | 506 | |
| 495 | 507 | foreach ( (array) get_post_custom() as $key => $val ) { |
| 496 | 508 | if ($key == 'enclosure') { |
@@ -618,8 +630,9 @@ discard block |
||
| 618 | 630 | * @since 2.8.0 |
| 619 | 631 | */ |
| 620 | 632 | function feed_content_type( $type = '' ) { |
| 621 | - if ( empty($type) ) |
|
| 622 | - $type = get_default_feed(); |
|
| 633 | + if ( empty($type) ) { |
|
| 634 | + $type = get_default_feed(); |
|
| 635 | + } |
|
| 623 | 636 | |
| 624 | 637 | $types = array( |
| 625 | 638 | 'rss' => 'application/rss+xml', |
@@ -683,8 +696,9 @@ discard block |
||
| 683 | 696 | $feed->set_output_encoding( get_option( 'blog_charset' ) ); |
| 684 | 697 | $feed->handle_content_type(); |
| 685 | 698 | |
| 686 | - if ( $feed->error() ) |
|
| 687 | - return new WP_Error( 'simplepie-error', $feed->error() ); |
|
| 699 | + if ( $feed->error() ) { |
|
| 700 | + return new WP_Error( 'simplepie-error', $feed->error() ); |
|
| 701 | + } |
|
| 688 | 702 | |
| 689 | 703 | return $feed; |
| 690 | 704 | } |
@@ -884,7 +884,7 @@ discard block |
||
| 884 | 884 | * @since 2.8.0 |
| 885 | 885 | * |
| 886 | 886 | * @param string $string The text which is to be decoded. |
| 887 | - * @param string|int $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
|
| 887 | + * @param integer $quote_style Optional. Converts double quotes if set to ENT_COMPAT, |
|
| 888 | 888 | * both single and double if set to ENT_QUOTES or |
| 889 | 889 | * none if set to ENT_NOQUOTES. |
| 890 | 890 | * Also compatible with old _wp_specialchars() values; |
@@ -2546,7 +2546,7 @@ discard block |
||
| 2546 | 2546 | * @since 1.5.0 |
| 2547 | 2547 | * |
| 2548 | 2548 | * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. |
| 2549 | - * @return int|float The offset in seconds. |
|
| 2549 | + * @return integer The offset in seconds. |
|
| 2550 | 2550 | */ |
| 2551 | 2551 | function iso8601_timezone_to_offset( $timezone ) { |
| 2552 | 2552 | // $timezone is either 'Z' or '[+|-]hhmm' |
@@ -3215,7 +3215,7 @@ discard block |
||
| 3215 | 3215 | * @since 2.8.1 |
| 3216 | 3216 | * @access private |
| 3217 | 3217 | * |
| 3218 | - * @param string|array $search The value being searched for, otherwise known as the needle. |
|
| 3218 | + * @param string[] $search The value being searched for, otherwise known as the needle. |
|
| 3219 | 3219 | * An array may be used to designate multiple needles. |
| 3220 | 3220 | * @param string $subject The string being searched and replaced on, otherwise known as the haystack. |
| 3221 | 3221 | * @return string The string with the replaced svalues. |
@@ -3795,7 +3795,6 @@ discard block |
||
| 3795 | 3795 | * @link http://www.php.net/sprintf |
| 3796 | 3796 | * |
| 3797 | 3797 | * @param string $pattern The string which formatted args are inserted. |
| 3798 | - * @param mixed $args ,... Arguments to be formatted into the $pattern string. |
|
| 3799 | 3798 | * @return string The formatted string. |
| 3800 | 3799 | */ |
| 3801 | 3800 | function wp_sprintf( $pattern ) { |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Main WordPress Formatting API. |
|
| 4 | - * |
|
| 5 | - * Handles many functions for formatting output. |
|
| 6 | - * |
|
| 7 | - * @package WordPress |
|
| 8 | - */ |
|
| 3 | + * Main WordPress Formatting API. |
|
| 4 | + * |
|
| 5 | + * Handles many functions for formatting output. |
|
| 6 | + * |
|
| 7 | + * @package WordPress |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Replaces common plain text characters into formatted entities |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | . '\\[' // Opening bracket |
| 742 | 742 | . "($tagregexp)" // 2: Shortcode name |
| 743 | 743 | . '(?![\\w-])' // Not followed by word character or hyphen |
| 744 | - // Unroll the loop: Inside the opening shortcode tag |
|
| 744 | + // Unroll the loop: Inside the opening shortcode tag |
|
| 745 | 745 | . '[^\\]\\/]*' // Not a closing bracket or forward slash |
| 746 | 746 | . '(?:' |
| 747 | 747 | . '\\/(?!\\])' // A forward slash not followed by a closing bracket |
@@ -2153,7 +2153,7 @@ discard block |
||
| 2153 | 2153 | ) |
| 2154 | 2154 | (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) |
| 2155 | 2155 | ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. |
| 2156 | - // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
|
| 2156 | + // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
|
| 2157 | 2157 | |
| 2158 | 2158 | $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); |
| 2159 | 2159 | |
@@ -3369,7 +3369,7 @@ discard block |
||
| 3369 | 3369 | * @since 2.0.6 |
| 3370 | 3370 | * |
| 3371 | 3371 | * @param string $safe_text The text after it has been escaped. |
| 3372 | - * @param string $text The text prior to being escaped. |
|
| 3372 | + * @param string $text The text prior to being escaped. |
|
| 3373 | 3373 | */ |
| 3374 | 3374 | return apply_filters( 'js_escape', $safe_text, $text ); |
| 3375 | 3375 | } |
@@ -3394,7 +3394,7 @@ discard block |
||
| 3394 | 3394 | * @since 2.8.0 |
| 3395 | 3395 | * |
| 3396 | 3396 | * @param string $safe_text The text after it has been escaped. |
| 3397 | - * @param string $text The text prior to being escaped. |
|
| 3397 | + * @param string $text The text prior to being escaped. |
|
| 3398 | 3398 | */ |
| 3399 | 3399 | return apply_filters( 'esc_html', $safe_text, $text ); |
| 3400 | 3400 | } |
@@ -3419,7 +3419,7 @@ discard block |
||
| 3419 | 3419 | * @since 2.0.6 |
| 3420 | 3420 | * |
| 3421 | 3421 | * @param string $safe_text The text after it has been escaped. |
| 3422 | - * @param string $text The text prior to being escaped. |
|
| 3422 | + * @param string $text The text prior to being escaped. |
|
| 3423 | 3423 | */ |
| 3424 | 3424 | return apply_filters( 'attribute_escape', $safe_text, $text ); |
| 3425 | 3425 | } |
@@ -3440,7 +3440,7 @@ discard block |
||
| 3440 | 3440 | * @since 3.1.0 |
| 3441 | 3441 | * |
| 3442 | 3442 | * @param string $safe_text The text after it has been escaped. |
| 3443 | - * @param string $text The text prior to being escaped. |
|
| 3443 | + * @param string $text The text prior to being escaped. |
|
| 3444 | 3444 | */ |
| 3445 | 3445 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 3446 | 3446 | } |
@@ -3461,7 +3461,7 @@ discard block |
||
| 3461 | 3461 | * @since 2.8.0 |
| 3462 | 3462 | * |
| 3463 | 3463 | * @param string $safe_tag The tag name after it has been escaped. |
| 3464 | - * @param string $tag_name The text before it was escaped. |
|
| 3464 | + * @param string $tag_name The text before it was escaped. |
|
| 3465 | 3465 | */ |
| 3466 | 3466 | return apply_filters( 'tag_escape', $safe_tag, $tag_name ); |
| 3467 | 3467 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param bool $reset Set to true for unit testing. Translated patterns will reset. |
| 39 | 39 | * @return string The string replaced with html entities |
| 40 | 40 | */ |
| 41 | -function wptexturize( $text, $reset = false ) { |
|
| 41 | +function wptexturize($text, $reset = false) { |
|
| 42 | 42 | global $wp_cockneyreplace, $shortcode_tags; |
| 43 | 43 | static $static_characters = null, |
| 44 | 44 | $static_replacements = null, |
@@ -59,12 +59,12 @@ discard block |
||
| 59 | 59 | $apos_flag = '<!--apos-->'; |
| 60 | 60 | |
| 61 | 61 | // If there's nothing to do, just stop. |
| 62 | - if ( empty( $text ) || false === $run_texturize ) { |
|
| 62 | + if (empty($text) || false === $run_texturize) { |
|
| 63 | 63 | return $text; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Set up static variables. Run once only. |
| 67 | - if ( $reset || ! isset( $static_characters ) ) { |
|
| 67 | + if ($reset || ! isset($static_characters)) { |
|
| 68 | 68 | /** |
| 69 | 69 | * Filter whether to skip running wptexturize(). |
| 70 | 70 | * |
@@ -79,118 +79,118 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param bool $run_texturize Whether to short-circuit wptexturize(). |
| 81 | 81 | */ |
| 82 | - $run_texturize = apply_filters( 'run_wptexturize', $run_texturize ); |
|
| 83 | - if ( false === $run_texturize ) { |
|
| 82 | + $run_texturize = apply_filters('run_wptexturize', $run_texturize); |
|
| 83 | + if (false === $run_texturize) { |
|
| 84 | 84 | return $text; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /* translators: opening curly double quote */ |
| 88 | - $opening_quote = _x( '“', 'opening curly double quote' ); |
|
| 88 | + $opening_quote = _x('“', 'opening curly double quote'); |
|
| 89 | 89 | /* translators: closing curly double quote */ |
| 90 | - $closing_quote = _x( '”', 'closing curly double quote' ); |
|
| 90 | + $closing_quote = _x('”', 'closing curly double quote'); |
|
| 91 | 91 | |
| 92 | 92 | /* translators: apostrophe, for example in 'cause or can't */ |
| 93 | - $apos = _x( '’', 'apostrophe' ); |
|
| 93 | + $apos = _x('’', 'apostrophe'); |
|
| 94 | 94 | |
| 95 | 95 | /* translators: prime, for example in 9' (nine feet) */ |
| 96 | - $prime = _x( '′', 'prime' ); |
|
| 96 | + $prime = _x('′', 'prime'); |
|
| 97 | 97 | /* translators: double prime, for example in 9" (nine inches) */ |
| 98 | - $double_prime = _x( '″', 'double prime' ); |
|
| 98 | + $double_prime = _x('″', 'double prime'); |
|
| 99 | 99 | |
| 100 | 100 | /* translators: opening curly single quote */ |
| 101 | - $opening_single_quote = _x( '‘', 'opening curly single quote' ); |
|
| 101 | + $opening_single_quote = _x('‘', 'opening curly single quote'); |
|
| 102 | 102 | /* translators: closing curly single quote */ |
| 103 | - $closing_single_quote = _x( '’', 'closing curly single quote' ); |
|
| 103 | + $closing_single_quote = _x('’', 'closing curly single quote'); |
|
| 104 | 104 | |
| 105 | 105 | /* translators: en dash */ |
| 106 | - $en_dash = _x( '–', 'en dash' ); |
|
| 106 | + $en_dash = _x('–', 'en dash'); |
|
| 107 | 107 | /* translators: em dash */ |
| 108 | - $em_dash = _x( '—', 'em dash' ); |
|
| 108 | + $em_dash = _x('—', 'em dash'); |
|
| 109 | 109 | |
| 110 | 110 | $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); |
| 111 | 111 | $default_no_texturize_shortcodes = array('code'); |
| 112 | 112 | |
| 113 | 113 | // if a plugin has provided an autocorrect array, use it |
| 114 | - if ( isset($wp_cockneyreplace) ) { |
|
| 115 | - $cockney = array_keys( $wp_cockneyreplace ); |
|
| 116 | - $cockneyreplace = array_values( $wp_cockneyreplace ); |
|
| 114 | + if (isset($wp_cockneyreplace)) { |
|
| 115 | + $cockney = array_keys($wp_cockneyreplace); |
|
| 116 | + $cockneyreplace = array_values($wp_cockneyreplace); |
|
| 117 | 117 | } else { |
| 118 | 118 | /* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, |
| 119 | 119 | * for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write |
| 120 | 120 | * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. |
| 121 | 121 | */ |
| 122 | - $cockney = explode( ',', _x( "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", |
|
| 123 | - 'Comma-separated list of words to texturize in your language' ) ); |
|
| 122 | + $cockney = explode(',', _x("'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", |
|
| 123 | + 'Comma-separated list of words to texturize in your language')); |
|
| 124 | 124 | |
| 125 | - $cockneyreplace = explode( ',', _x( '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', |
|
| 126 | - 'Comma-separated list of replacement words in your language' ) ); |
|
| 125 | + $cockneyreplace = explode(',', _x('’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', |
|
| 126 | + 'Comma-separated list of replacement words in your language')); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); |
|
| 130 | - $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); |
|
| 129 | + $static_characters = array_merge(array('...', '``', '\'\'', ' (tm)'), $cockney); |
|
| 130 | + $static_replacements = array_merge(array('…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace); |
|
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | // Pattern-based replacements of characters. |
| 134 | 134 | // Sort the remaining patterns into several arrays for performance tuning. |
| 135 | - $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); |
|
| 136 | - $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); |
|
| 135 | + $dynamic_characters = array('apos' => array(), 'quote' => array(), 'dash' => array()); |
|
| 136 | + $dynamic_replacements = array('apos' => array(), 'quote' => array(), 'dash' => array()); |
|
| 137 | 137 | $dynamic = array(); |
| 138 | 138 | $spaces = wp_spaces_regexp(); |
| 139 | 139 | |
| 140 | 140 | // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. |
| 141 | - if ( "'" !== $apos || "'" !== $closing_single_quote ) { |
|
| 142 | - $dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_single_quote; |
|
| 141 | + if ("'" !== $apos || "'" !== $closing_single_quote) { |
|
| 142 | + $dynamic['/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|'.$spaces.')/'] = $apos_flag.'$1'.$closing_single_quote; |
|
| 143 | 143 | } |
| 144 | - if ( "'" !== $apos || '"' !== $closing_quote ) { |
|
| 145 | - $dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos_flag . '$1' . $closing_quote; |
|
| 144 | + if ("'" !== $apos || '"' !== $closing_quote) { |
|
| 145 | + $dynamic['/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|'.$spaces.')/'] = $apos_flag.'$1'.$closing_quote; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. |
| 149 | - if ( "'" !== $apos ) { |
|
| 150 | - $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos_flag; |
|
| 149 | + if ("'" !== $apos) { |
|
| 150 | + $dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Quoted Numbers like '0.42' |
| 154 | - if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { |
|
| 155 | - $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; |
|
| 154 | + if ("'" !== $opening_single_quote && "'" !== $closing_single_quote) { |
|
| 155 | + $dynamic['/(?<=\A|'.$spaces.')\'(\d[.,\d]*)\'/'] = $open_sq_flag.'$1'.$closing_single_quote; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Single quote at start, or preceded by (, {, <, [, ", -, or spaces. |
| 159 | - if ( "'" !== $opening_single_quote ) { |
|
| 160 | - $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; |
|
| 159 | + if ("'" !== $opening_single_quote) { |
|
| 160 | + $dynamic['/(?<=\A|[([{"\-]|<|'.$spaces.')\'/'] = $open_sq_flag; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. |
| 164 | - if ( "'" !== $apos ) { |
|
| 165 | - $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag; |
|
| 164 | + if ("'" !== $apos) { |
|
| 165 | + $dynamic['/(?<!'.$spaces.')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|'.$spaces.')/'] = $apos_flag; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - $dynamic_characters['apos'] = array_keys( $dynamic ); |
|
| 169 | - $dynamic_replacements['apos'] = array_values( $dynamic ); |
|
| 168 | + $dynamic_characters['apos'] = array_keys($dynamic); |
|
| 169 | + $dynamic_replacements['apos'] = array_values($dynamic); |
|
| 170 | 170 | $dynamic = array(); |
| 171 | 171 | |
| 172 | 172 | // Quoted Numbers like "42" |
| 173 | - if ( '"' !== $opening_quote && '"' !== $closing_quote ) { |
|
| 174 | - $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote; |
|
| 173 | + if ('"' !== $opening_quote && '"' !== $closing_quote) { |
|
| 174 | + $dynamic['/(?<=\A|'.$spaces.')"(\d[.,\d]*)"/'] = $open_q_flag.'$1'.$closing_quote; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. |
| 178 | - if ( '"' !== $opening_quote ) { |
|
| 179 | - $dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $open_q_flag; |
|
| 178 | + if ('"' !== $opening_quote) { |
|
| 179 | + $dynamic['/(?<=\A|[([{\-]|<|'.$spaces.')"(?!'.$spaces.')/'] = $open_q_flag; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - $dynamic_characters['quote'] = array_keys( $dynamic ); |
|
| 183 | - $dynamic_replacements['quote'] = array_values( $dynamic ); |
|
| 182 | + $dynamic_characters['quote'] = array_keys($dynamic); |
|
| 183 | + $dynamic_replacements['quote'] = array_values($dynamic); |
|
| 184 | 184 | $dynamic = array(); |
| 185 | 185 | |
| 186 | 186 | // Dashes and spaces |
| 187 | - $dynamic[ '/---/' ] = $em_dash; |
|
| 188 | - $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; |
|
| 189 | - $dynamic[ '/(?<!xn)--/' ] = $en_dash; |
|
| 190 | - $dynamic[ '/(?<=^|' . $spaces . ')-(?=$|' . $spaces . ')/' ] = $en_dash; |
|
| 187 | + $dynamic['/---/'] = $em_dash; |
|
| 188 | + $dynamic['/(?<=^|'.$spaces.')--(?=$|'.$spaces.')/'] = $em_dash; |
|
| 189 | + $dynamic['/(?<!xn)--/'] = $en_dash; |
|
| 190 | + $dynamic['/(?<=^|'.$spaces.')-(?=$|'.$spaces.')/'] = $en_dash; |
|
| 191 | 191 | |
| 192 | - $dynamic_characters['dash'] = array_keys( $dynamic ); |
|
| 193 | - $dynamic_replacements['dash'] = array_values( $dynamic ); |
|
| 192 | + $dynamic_characters['dash'] = array_keys($dynamic); |
|
| 193 | + $dynamic_replacements['dash'] = array_values($dynamic); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Must do this every time in case plugins use these filters in a context sensitive manner |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @param array $default_no_texturize_tags An array of HTML element names. |
| 203 | 203 | */ |
| 204 | - $no_texturize_tags = apply_filters( 'no_texturize_tags', $default_no_texturize_tags ); |
|
| 204 | + $no_texturize_tags = apply_filters('no_texturize_tags', $default_no_texturize_tags); |
|
| 205 | 205 | /** |
| 206 | 206 | * Filter the list of shortcodes not to texturize. |
| 207 | 207 | * |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @param array $default_no_texturize_shortcodes An array of shortcode names. |
| 211 | 211 | */ |
| 212 | - $no_texturize_shortcodes = apply_filters( 'no_texturize_shortcodes', $default_no_texturize_shortcodes ); |
|
| 212 | + $no_texturize_shortcodes = apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes); |
|
| 213 | 213 | |
| 214 | 214 | $no_texturize_tags_stack = array(); |
| 215 | 215 | $no_texturize_shortcodes_stack = array(); |
| 216 | 216 | |
| 217 | 217 | // Look for shortcodes and HTML elements. |
| 218 | 218 | |
| 219 | - $tagnames = array_keys( $shortcode_tags ); |
|
| 220 | - $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); |
|
| 219 | + $tagnames = array_keys($shortcode_tags); |
|
| 220 | + $tagregexp = join('|', array_map('preg_quote', $tagnames)); |
|
| 221 | 221 | $tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex(). |
| 222 | 222 | |
| 223 | 223 | $comment_regex = |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | . '-(?!->)' // Dash not followed by end of comment. |
| 227 | 227 | . '[^\-]*+' // Consume non-dashes. |
| 228 | 228 | . ')*+' // Loop possessively. |
| 229 | - . '(?:-->)?'; // End of comment. If not found, match all input. |
|
| 229 | + . '(?:-->)?'; // End of comment. If not found, match all input. |
|
| 230 | 230 | |
| 231 | 231 | $shortcode_regex = |
| 232 | 232 | '\[' // Find start of shortcode. |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. |
| 239 | 239 | . ')*+' // Possessive critical. |
| 240 | 240 | . '\]' // Find end of shortcode. |
| 241 | - . '\]?'; // Shortcodes may end with ]] |
|
| 241 | + . '\]?'; // Shortcodes may end with ]] |
|
| 242 | 242 | |
| 243 | 243 | $regex = |
| 244 | 244 | '/(' // Capture the entire match. |
@@ -252,68 +252,68 @@ discard block |
||
| 252 | 252 | . $shortcode_regex // Find shortcodes. |
| 253 | 253 | . ')/s'; |
| 254 | 254 | |
| 255 | - $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); |
|
| 255 | + $textarr = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
|
| 256 | 256 | |
| 257 | - foreach ( $textarr as &$curl ) { |
|
| 257 | + foreach ($textarr as &$curl) { |
|
| 258 | 258 | // Only call _wptexturize_pushpop_element if $curl is a delimiter. |
| 259 | 259 | $first = $curl[0]; |
| 260 | - if ( '<' === $first && '<!--' === substr( $curl, 0, 4 ) ) { |
|
| 260 | + if ('<' === $first && '<!--' === substr($curl, 0, 4)) { |
|
| 261 | 261 | // This is an HTML comment delimeter. |
| 262 | 262 | |
| 263 | 263 | continue; |
| 264 | 264 | |
| 265 | - } elseif ( '<' === $first && '>' === substr( $curl, -1 ) ) { |
|
| 265 | + } elseif ('<' === $first && '>' === substr($curl, -1)) { |
|
| 266 | 266 | // This is an HTML element delimiter. |
| 267 | 267 | |
| 268 | - _wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags ); |
|
| 268 | + _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags); |
|
| 269 | 269 | |
| 270 | - } elseif ( '' === trim( $curl ) ) { |
|
| 270 | + } elseif ('' === trim($curl)) { |
|
| 271 | 271 | // This is a newline between delimiters. Performance improves when we check this. |
| 272 | 272 | |
| 273 | 273 | continue; |
| 274 | 274 | |
| 275 | - } elseif ( '[' === $first && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) { |
|
| 275 | + } elseif ('[' === $first && 1 === preg_match('/^'.$shortcode_regex.'$/', $curl)) { |
|
| 276 | 276 | // This is a shortcode delimiter. |
| 277 | 277 | |
| 278 | - if ( '[[' !== substr( $curl, 0, 2 ) && ']]' !== substr( $curl, -2 ) ) { |
|
| 278 | + if ('[[' !== substr($curl, 0, 2) && ']]' !== substr($curl, -2)) { |
|
| 279 | 279 | // Looks like a normal shortcode. |
| 280 | - _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); |
|
| 280 | + _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes); |
|
| 281 | 281 | } else { |
| 282 | 282 | // Looks like an escaped shortcode. |
| 283 | 283 | continue; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - } elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { |
|
| 286 | + } elseif (empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) { |
|
| 287 | 287 | // This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. |
| 288 | 288 | |
| 289 | - $curl = str_replace( $static_characters, $static_replacements, $curl ); |
|
| 289 | + $curl = str_replace($static_characters, $static_replacements, $curl); |
|
| 290 | 290 | |
| 291 | - if ( false !== strpos( $curl, "'" ) ) { |
|
| 292 | - $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); |
|
| 293 | - $curl = wptexturize_primes( $curl, "'", $prime, $open_sq_flag, $closing_single_quote ); |
|
| 294 | - $curl = str_replace( $apos_flag, $apos, $curl ); |
|
| 295 | - $curl = str_replace( $open_sq_flag, $opening_single_quote, $curl ); |
|
| 291 | + if (false !== strpos($curl, "'")) { |
|
| 292 | + $curl = preg_replace($dynamic_characters['apos'], $dynamic_replacements['apos'], $curl); |
|
| 293 | + $curl = wptexturize_primes($curl, "'", $prime, $open_sq_flag, $closing_single_quote); |
|
| 294 | + $curl = str_replace($apos_flag, $apos, $curl); |
|
| 295 | + $curl = str_replace($open_sq_flag, $opening_single_quote, $curl); |
|
| 296 | 296 | } |
| 297 | - if ( false !== strpos( $curl, '"' ) ) { |
|
| 298 | - $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); |
|
| 299 | - $curl = wptexturize_primes( $curl, '"', $double_prime, $open_q_flag, $closing_quote ); |
|
| 300 | - $curl = str_replace( $open_q_flag, $opening_quote, $curl ); |
|
| 297 | + if (false !== strpos($curl, '"')) { |
|
| 298 | + $curl = preg_replace($dynamic_characters['quote'], $dynamic_replacements['quote'], $curl); |
|
| 299 | + $curl = wptexturize_primes($curl, '"', $double_prime, $open_q_flag, $closing_quote); |
|
| 300 | + $curl = str_replace($open_q_flag, $opening_quote, $curl); |
|
| 301 | 301 | } |
| 302 | - if ( false !== strpos( $curl, '-' ) ) { |
|
| 303 | - $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); |
|
| 302 | + if (false !== strpos($curl, '-')) { |
|
| 303 | + $curl = preg_replace($dynamic_characters['dash'], $dynamic_replacements['dash'], $curl); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // 9x9 (times), but never 0x9999 |
| 307 | - if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) { |
|
| 307 | + if (1 === preg_match('/(?<=\d)x\d/', $curl)) { |
|
| 308 | 308 | // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! |
| 309 | - $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); |
|
| 309 | + $curl = preg_replace('/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl); |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | - $text = implode( '', $textarr ); |
|
| 313 | + $text = implode('', $textarr); |
|
| 314 | 314 | |
| 315 | 315 | // Replace each & with & unless it already looks like an entity. |
| 316 | - return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text ); |
|
| 316 | + return preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
@@ -330,59 +330,59 @@ discard block |
||
| 330 | 330 | * @param string $close_quote The closing quote char to use for replacement. |
| 331 | 331 | * @return string The $haystack value after primes and quotes replacements. |
| 332 | 332 | */ |
| 333 | -function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) { |
|
| 333 | +function wptexturize_primes($haystack, $needle, $prime, $open_quote, $close_quote) { |
|
| 334 | 334 | $spaces = wp_spaces_regexp(); |
| 335 | 335 | $flag = '<!--wp-prime-or-quote-->'; |
| 336 | - $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ")/"; |
|
| 336 | + $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|".$spaces.")/"; |
|
| 337 | 337 | $prime_pattern = "/(?<=\\d)$needle/"; |
| 338 | 338 | $flag_after_digit = "/(?<=\\d)$flag/"; |
| 339 | 339 | $flag_no_digit = "/(?<!\\d)$flag/"; |
| 340 | 340 | |
| 341 | - $sentences = explode( $open_quote, $haystack ); |
|
| 341 | + $sentences = explode($open_quote, $haystack); |
|
| 342 | 342 | |
| 343 | - foreach( $sentences as $key => &$sentence ) { |
|
| 344 | - if ( false === strpos( $sentence, $needle ) ) { |
|
| 343 | + foreach ($sentences as $key => &$sentence) { |
|
| 344 | + if (false === strpos($sentence, $needle)) { |
|
| 345 | 345 | continue; |
| 346 | - } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { |
|
| 347 | - $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); |
|
| 348 | - if ( $count > 1 ) { |
|
| 346 | + } elseif (0 !== $key && 0 === substr_count($sentence, $close_quote)) { |
|
| 347 | + $sentence = preg_replace($quote_pattern, $flag, $sentence, -1, $count); |
|
| 348 | + if ($count > 1) { |
|
| 349 | 349 | // This sentence appears to have multiple closing quotes. Attempt Vulcan logic. |
| 350 | - $sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); |
|
| 351 | - if ( 0 === $count2 ) { |
|
| 350 | + $sentence = preg_replace($flag_no_digit, $close_quote, $sentence, -1, $count2); |
|
| 351 | + if (0 === $count2) { |
|
| 352 | 352 | // Try looking for a quote followed by a period. |
| 353 | - $count2 = substr_count( $sentence, "$flag." ); |
|
| 354 | - if ( $count2 > 0 ) { |
|
| 353 | + $count2 = substr_count($sentence, "$flag."); |
|
| 354 | + if ($count2 > 0) { |
|
| 355 | 355 | // Assume the rightmost quote-period match is the end of quotation. |
| 356 | - $pos = strrpos( $sentence, "$flag." ); |
|
| 356 | + $pos = strrpos($sentence, "$flag."); |
|
| 357 | 357 | } else { |
| 358 | 358 | // When all else fails, make the rightmost candidate a closing quote. |
| 359 | 359 | // This is most likely to be problematic in the context of bug #18549. |
| 360 | - $pos = strrpos( $sentence, $flag ); |
|
| 360 | + $pos = strrpos($sentence, $flag); |
|
| 361 | 361 | } |
| 362 | - $sentence = substr_replace( $sentence, $close_quote, $pos, strlen( $flag ) ); |
|
| 362 | + $sentence = substr_replace($sentence, $close_quote, $pos, strlen($flag)); |
|
| 363 | 363 | } |
| 364 | 364 | // Use conventional replacement on any remaining primes and quotes. |
| 365 | - $sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
|
| 366 | - $sentence = preg_replace( $flag_after_digit, $prime, $sentence ); |
|
| 367 | - $sentence = str_replace( $flag, $close_quote, $sentence ); |
|
| 368 | - } elseif ( 1 == $count ) { |
|
| 365 | + $sentence = preg_replace($prime_pattern, $prime, $sentence); |
|
| 366 | + $sentence = preg_replace($flag_after_digit, $prime, $sentence); |
|
| 367 | + $sentence = str_replace($flag, $close_quote, $sentence); |
|
| 368 | + } elseif (1 == $count) { |
|
| 369 | 369 | // Found only one closing quote candidate, so give it priority over primes. |
| 370 | - $sentence = str_replace( $flag, $close_quote, $sentence ); |
|
| 371 | - $sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
|
| 370 | + $sentence = str_replace($flag, $close_quote, $sentence); |
|
| 371 | + $sentence = preg_replace($prime_pattern, $prime, $sentence); |
|
| 372 | 372 | } else { |
| 373 | 373 | // No closing quotes found. Just run primes pattern. |
| 374 | - $sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
|
| 374 | + $sentence = preg_replace($prime_pattern, $prime, $sentence); |
|
| 375 | 375 | } |
| 376 | 376 | } else { |
| 377 | - $sentence = preg_replace( $prime_pattern, $prime, $sentence ); |
|
| 378 | - $sentence = preg_replace( $quote_pattern, $close_quote, $sentence ); |
|
| 377 | + $sentence = preg_replace($prime_pattern, $prime, $sentence); |
|
| 378 | + $sentence = preg_replace($quote_pattern, $close_quote, $sentence); |
|
| 379 | 379 | } |
| 380 | - if ( '"' == $needle && false !== strpos( $sentence, '"' ) ) { |
|
| 381 | - $sentence = str_replace( '"', $close_quote, $sentence ); |
|
| 380 | + if ('"' == $needle && false !== strpos($sentence, '"')) { |
|
| 381 | + $sentence = str_replace('"', $close_quote, $sentence); |
|
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - return implode( $open_quote, $sentences ); |
|
| 385 | + return implode($open_quote, $sentences); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -399,12 +399,12 @@ discard block |
||
| 399 | 399 | * @param array $stack List of open tag elements. |
| 400 | 400 | * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names. |
| 401 | 401 | */ |
| 402 | -function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { |
|
| 402 | +function _wptexturize_pushpop_element($text, &$stack, $disabled_elements) { |
|
| 403 | 403 | // Is it an opening tag or closing tag? |
| 404 | - if ( '/' !== $text[1] ) { |
|
| 404 | + if ('/' !== $text[1]) { |
|
| 405 | 405 | $opening_tag = true; |
| 406 | 406 | $name_offset = 1; |
| 407 | - } elseif ( 0 == count( $stack ) ) { |
|
| 407 | + } elseif (0 == count($stack)) { |
|
| 408 | 408 | // Stack is empty. Just stop. |
| 409 | 409 | return; |
| 410 | 410 | } else { |
@@ -413,17 +413,17 @@ discard block |
||
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // Parse out the tag name. |
| 416 | - $space = strpos( $text, ' ' ); |
|
| 417 | - if ( false === $space ) { |
|
| 416 | + $space = strpos($text, ' '); |
|
| 417 | + if (false === $space) { |
|
| 418 | 418 | $space = -1; |
| 419 | 419 | } else { |
| 420 | 420 | $space -= $name_offset; |
| 421 | 421 | } |
| 422 | - $tag = substr( $text, $name_offset, $space ); |
|
| 422 | + $tag = substr($text, $name_offset, $space); |
|
| 423 | 423 | |
| 424 | 424 | // Handle disabled tags. |
| 425 | - if ( in_array( $tag, $disabled_elements ) ) { |
|
| 426 | - if ( $opening_tag ) { |
|
| 425 | + if (in_array($tag, $disabled_elements)) { |
|
| 426 | + if ($opening_tag) { |
|
| 427 | 427 | /* |
| 428 | 428 | * This disables texturize until we find a closing tag of our type |
| 429 | 429 | * (e.g. <pre>) even if there was invalid nesting before that |
@@ -432,9 +432,9 @@ discard block |
||
| 432 | 432 | * "baba" won't be texturize |
| 433 | 433 | */ |
| 434 | 434 | |
| 435 | - array_push( $stack, $tag ); |
|
| 436 | - } elseif ( end( $stack ) == $tag ) { |
|
| 437 | - array_pop( $stack ); |
|
| 435 | + array_push($stack, $tag); |
|
| 436 | + } elseif (end($stack) == $tag) { |
|
| 437 | + array_pop($stack); |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | 440 | } |
@@ -453,38 +453,38 @@ discard block |
||
| 453 | 453 | * after paragraphing. Default true. |
| 454 | 454 | * @return string Text which has been converted into correct paragraph tags. |
| 455 | 455 | */ |
| 456 | -function wpautop( $pee, $br = true ) { |
|
| 456 | +function wpautop($pee, $br = true) { |
|
| 457 | 457 | $pre_tags = array(); |
| 458 | 458 | |
| 459 | - if ( trim($pee) === '' ) |
|
| 459 | + if (trim($pee) === '') |
|
| 460 | 460 | return ''; |
| 461 | 461 | |
| 462 | 462 | // Just to make things a little easier, pad the end. |
| 463 | - $pee = $pee . "\n"; |
|
| 463 | + $pee = $pee."\n"; |
|
| 464 | 464 | |
| 465 | 465 | /* |
| 466 | 466 | * Pre tags shouldn't be touched by autop. |
| 467 | 467 | * Replace pre tags with placeholders and bring them back after autop. |
| 468 | 468 | */ |
| 469 | - if ( strpos($pee, '<pre') !== false ) { |
|
| 470 | - $pee_parts = explode( '</pre>', $pee ); |
|
| 469 | + if (strpos($pee, '<pre') !== false) { |
|
| 470 | + $pee_parts = explode('</pre>', $pee); |
|
| 471 | 471 | $last_pee = array_pop($pee_parts); |
| 472 | 472 | $pee = ''; |
| 473 | 473 | $i = 0; |
| 474 | 474 | |
| 475 | - foreach ( $pee_parts as $pee_part ) { |
|
| 475 | + foreach ($pee_parts as $pee_part) { |
|
| 476 | 476 | $start = strpos($pee_part, '<pre'); |
| 477 | 477 | |
| 478 | 478 | // Malformed html? |
| 479 | - if ( $start === false ) { |
|
| 479 | + if ($start === false) { |
|
| 480 | 480 | $pee .= $pee_part; |
| 481 | 481 | continue; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | $name = "<pre wp-pre-tag-$i></pre>"; |
| 485 | - $pre_tags[$name] = substr( $pee_part, $start ) . '</pre>'; |
|
| 485 | + $pre_tags[$name] = substr($pee_part, $start).'</pre>'; |
|
| 486 | 486 | |
| 487 | - $pee .= substr( $pee_part, 0, $start ) . $name; |
|
| 487 | + $pee .= substr($pee_part, 0, $start).$name; |
|
| 488 | 488 | $i++; |
| 489 | 489 | } |
| 490 | 490 | |
@@ -496,41 +496,41 @@ discard block |
||
| 496 | 496 | $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; |
| 497 | 497 | |
| 498 | 498 | // Add a single line break above block-level opening tags. |
| 499 | - $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); |
|
| 499 | + $pee = preg_replace('!(<'.$allblocks.'[^>]*>)!', "\n$1", $pee); |
|
| 500 | 500 | |
| 501 | 501 | // Add a double line break below block-level closing tags. |
| 502 | - $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee); |
|
| 502 | + $pee = preg_replace('!(</'.$allblocks.'>)!', "$1\n\n", $pee); |
|
| 503 | 503 | |
| 504 | 504 | // Standardize newline characters to "\n". |
| 505 | 505 | $pee = str_replace(array("\r\n", "\r"), "\n", $pee); |
| 506 | 506 | |
| 507 | 507 | // Find newlines in all elements and add placeholders. |
| 508 | - $pee = wp_replace_in_html_tags( $pee, array( "\n" => " <!-- wpnl --> " ) ); |
|
| 508 | + $pee = wp_replace_in_html_tags($pee, array("\n" => " <!-- wpnl --> ")); |
|
| 509 | 509 | |
| 510 | 510 | // Collapse line breaks before and after <option> elements so they don't get autop'd. |
| 511 | - if ( strpos( $pee, '<option' ) !== false ) { |
|
| 512 | - $pee = preg_replace( '|\s*<option|', '<option', $pee ); |
|
| 513 | - $pee = preg_replace( '|</option>\s*|', '</option>', $pee ); |
|
| 511 | + if (strpos($pee, '<option') !== false) { |
|
| 512 | + $pee = preg_replace('|\s*<option|', '<option', $pee); |
|
| 513 | + $pee = preg_replace('|</option>\s*|', '</option>', $pee); |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /* |
| 517 | 517 | * Collapse line breaks inside <object> elements, before <param> and <embed> elements |
| 518 | 518 | * so they don't get autop'd. |
| 519 | 519 | */ |
| 520 | - if ( strpos( $pee, '</object>' ) !== false ) { |
|
| 521 | - $pee = preg_replace( '|(<object[^>]*>)\s*|', '$1', $pee ); |
|
| 522 | - $pee = preg_replace( '|\s*</object>|', '</object>', $pee ); |
|
| 523 | - $pee = preg_replace( '%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee ); |
|
| 520 | + if (strpos($pee, '</object>') !== false) { |
|
| 521 | + $pee = preg_replace('|(<object[^>]*>)\s*|', '$1', $pee); |
|
| 522 | + $pee = preg_replace('|\s*</object>|', '</object>', $pee); |
|
| 523 | + $pee = preg_replace('%\s*(</?(?:param|embed)[^>]*>)\s*%', '$1', $pee); |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /* |
| 527 | 527 | * Collapse line breaks inside <audio> and <video> elements, |
| 528 | 528 | * before and after <source> and <track> elements. |
| 529 | 529 | */ |
| 530 | - if ( strpos( $pee, '<source' ) !== false || strpos( $pee, '<track' ) !== false ) { |
|
| 531 | - $pee = preg_replace( '%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee ); |
|
| 532 | - $pee = preg_replace( '%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee ); |
|
| 533 | - $pee = preg_replace( '%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee ); |
|
| 530 | + if (strpos($pee, '<source') !== false || strpos($pee, '<track') !== false) { |
|
| 531 | + $pee = preg_replace('%([<\[](?:audio|video)[^>\]]*[>\]])\s*%', '$1', $pee); |
|
| 532 | + $pee = preg_replace('%\s*([<\[]/(?:audio|video)[>\]])%', '$1', $pee); |
|
| 533 | + $pee = preg_replace('%\s*(<(?:source|track)[^>]*>)\s*%', '$1', $pee); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | // Remove more than two contiguous line breaks. |
@@ -543,8 +543,8 @@ discard block |
||
| 543 | 543 | $pee = ''; |
| 544 | 544 | |
| 545 | 545 | // Rebuild the content as a string, wrapping every bit with a <p>. |
| 546 | - foreach ( $pees as $tinkle ) { |
|
| 547 | - $pee .= '<p>' . trim($tinkle, "\n") . "</p>\n"; |
|
| 546 | + foreach ($pees as $tinkle) { |
|
| 547 | + $pee .= '<p>'.trim($tinkle, "\n")."</p>\n"; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | // Under certain strange conditions it could create a P of entirely whitespace. |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | $pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', "<p>$1</p></$2>", $pee); |
| 555 | 555 | |
| 556 | 556 | // If an opening or closing block element tag is wrapped in a <p>, unwrap it. |
| 557 | - $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); |
|
| 557 | + $pee = preg_replace('!<p>\s*(</?'.$allblocks.'[^>]*>)\s*</p>!', "$1", $pee); |
|
| 558 | 558 | |
| 559 | 559 | // In some cases <li> may get wrapped in <p>, fix them. |
| 560 | 560 | $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); |
@@ -564,18 +564,18 @@ discard block |
||
| 564 | 564 | $pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee); |
| 565 | 565 | |
| 566 | 566 | // If an opening or closing block element tag is preceded by an opening <p> tag, remove it. |
| 567 | - $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); |
|
| 567 | + $pee = preg_replace('!<p>\s*(</?'.$allblocks.'[^>]*>)!', "$1", $pee); |
|
| 568 | 568 | |
| 569 | 569 | // If an opening or closing block element tag is followed by a closing <p> tag, remove it. |
| 570 | - $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); |
|
| 570 | + $pee = preg_replace('!(</?'.$allblocks.'[^>]*>)\s*</p>!', "$1", $pee); |
|
| 571 | 571 | |
| 572 | 572 | // Optionally insert line breaks. |
| 573 | - if ( $br ) { |
|
| 573 | + if ($br) { |
|
| 574 | 574 | // Replace newlines that shouldn't be touched with a placeholder. |
| 575 | 575 | $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); |
| 576 | 576 | |
| 577 | 577 | // Normalize <br> |
| 578 | - $pee = str_replace( array( '<br>', '<br/>' ), '<br />', $pee ); |
|
| 578 | + $pee = str_replace(array('<br>', '<br/>'), '<br />', $pee); |
|
| 579 | 579 | |
| 580 | 580 | // Replace any new line characters that aren't preceded by a <br /> with a <br />. |
| 581 | 581 | $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); |
@@ -585,18 +585,18 @@ discard block |
||
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // If a <br /> tag is after an opening or closing block tag, remove it. |
| 588 | - $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); |
|
| 588 | + $pee = preg_replace('!(</?'.$allblocks.'[^>]*>)\s*<br />!', "$1", $pee); |
|
| 589 | 589 | |
| 590 | 590 | // If a <br /> tag is before a subset of opening or closing block tags, remove it. |
| 591 | 591 | $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); |
| 592 | - $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); |
|
| 592 | + $pee = preg_replace("|\n</p>$|", '</p>', $pee); |
|
| 593 | 593 | |
| 594 | 594 | // Replace placeholder <pre> tags with their original content. |
| 595 | - if ( !empty($pre_tags) ) |
|
| 595 | + if ( ! empty($pre_tags)) |
|
| 596 | 596 | $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); |
| 597 | 597 | |
| 598 | 598 | // Restore newlines in all elements. |
| 599 | - $pee = str_replace( " <!-- wpnl --> ", "\n", $pee ); |
|
| 599 | + $pee = str_replace(" <!-- wpnl --> ", "\n", $pee); |
|
| 600 | 600 | |
| 601 | 601 | return $pee; |
| 602 | 602 | } |
@@ -609,17 +609,17 @@ discard block |
||
| 609 | 609 | * @param string $input The text which has to be formatted. |
| 610 | 610 | * @return array The formatted text. |
| 611 | 611 | */ |
| 612 | -function wp_html_split( $input ) { |
|
| 612 | +function wp_html_split($input) { |
|
| 613 | 613 | static $regex; |
| 614 | 614 | |
| 615 | - if ( ! isset( $regex ) ) { |
|
| 615 | + if ( ! isset($regex)) { |
|
| 616 | 616 | $comments = |
| 617 | 617 | '!' // Start of comment, after the <. |
| 618 | 618 | . '(?:' // Unroll the loop: Consume everything until --> is found. |
| 619 | 619 | . '-(?!->)' // Dash not followed by end of comment. |
| 620 | 620 | . '[^\-]*+' // Consume non-dashes. |
| 621 | 621 | . ')*+' // Loop possessively. |
| 622 | - . '(?:-->)?'; // End of comment. If not found, match all input. |
|
| 622 | + . '(?:-->)?'; // End of comment. If not found, match all input. |
|
| 623 | 623 | |
| 624 | 624 | $cdata = |
| 625 | 625 | '!\[CDATA\[' // Start of comment, after the <. |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | . '](?!]>)' // One ] not followed by end of comment. |
| 629 | 629 | . '[^\]]*+' // Consume non-]. |
| 630 | 630 | . ')*+' // Loop possessively. |
| 631 | - . '(?:]]>)?'; // End of comment. If not found, match all input. |
|
| 631 | + . '(?:]]>)?'; // End of comment. If not found, match all input. |
|
| 632 | 632 | |
| 633 | 633 | $regex = |
| 634 | 634 | '/(' // Capture the entire match. |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | . ')/s'; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - return preg_split( $regex, $input, -1, PREG_SPLIT_DELIM_CAPTURE ); |
|
| 648 | + return preg_split($regex, $input, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | /** |
@@ -657,32 +657,32 @@ discard block |
||
| 657 | 657 | * @param array $replace_pairs In the form array('from' => 'to', ...). |
| 658 | 658 | * @return string The formatted text. |
| 659 | 659 | */ |
| 660 | -function wp_replace_in_html_tags( $haystack, $replace_pairs ) { |
|
| 660 | +function wp_replace_in_html_tags($haystack, $replace_pairs) { |
|
| 661 | 661 | // Find all elements. |
| 662 | - $textarr = wp_html_split( $haystack ); |
|
| 662 | + $textarr = wp_html_split($haystack); |
|
| 663 | 663 | $changed = false; |
| 664 | 664 | |
| 665 | 665 | // Optimize when searching for one item. |
| 666 | - if ( 1 === count( $replace_pairs ) ) { |
|
| 666 | + if (1 === count($replace_pairs)) { |
|
| 667 | 667 | // Extract $needle and $replace. |
| 668 | - foreach ( $replace_pairs as $needle => $replace ); |
|
| 668 | + foreach ($replace_pairs as $needle => $replace); |
|
| 669 | 669 | |
| 670 | 670 | // Loop through delimeters (elements) only. |
| 671 | - for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
|
| 672 | - if ( false !== strpos( $textarr[$i], $needle ) ) { |
|
| 673 | - $textarr[$i] = str_replace( $needle, $replace, $textarr[$i] ); |
|
| 671 | + for ($i = 1, $c = count($textarr); $i < $c; $i += 2) { |
|
| 672 | + if (false !== strpos($textarr[$i], $needle)) { |
|
| 673 | + $textarr[$i] = str_replace($needle, $replace, $textarr[$i]); |
|
| 674 | 674 | $changed = true; |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | } else { |
| 678 | 678 | // Extract all $needles. |
| 679 | - $needles = array_keys( $replace_pairs ); |
|
| 679 | + $needles = array_keys($replace_pairs); |
|
| 680 | 680 | |
| 681 | 681 | // Loop through delimeters (elements) only. |
| 682 | - for ( $i = 1, $c = count( $textarr ); $i < $c; $i += 2 ) { |
|
| 683 | - foreach ( $needles as $needle ) { |
|
| 684 | - if ( false !== strpos( $textarr[$i], $needle ) ) { |
|
| 685 | - $textarr[$i] = strtr( $textarr[$i], $replace_pairs ); |
|
| 682 | + for ($i = 1, $c = count($textarr); $i < $c; $i += 2) { |
|
| 683 | + foreach ($needles as $needle) { |
|
| 684 | + if (false !== strpos($textarr[$i], $needle)) { |
|
| 685 | + $textarr[$i] = strtr($textarr[$i], $replace_pairs); |
|
| 686 | 686 | $changed = true; |
| 687 | 687 | // After one strtr() break out of the foreach loop and look at next element. |
| 688 | 688 | break; |
@@ -691,8 +691,8 @@ discard block |
||
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | - if ( $changed ) { |
|
| 695 | - $haystack = implode( $textarr ); |
|
| 694 | + if ($changed) { |
|
| 695 | + $haystack = implode($textarr); |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | return $haystack; |
@@ -707,8 +707,8 @@ discard block |
||
| 707 | 707 | * @param array $matches preg_replace_callback matches array |
| 708 | 708 | * @return string |
| 709 | 709 | */ |
| 710 | -function _autop_newline_preservation_helper( $matches ) { |
|
| 711 | - return str_replace( "\n", "<WPPreserveNewline />", $matches[0] ); |
|
| 710 | +function _autop_newline_preservation_helper($matches) { |
|
| 711 | + return str_replace("\n", "<WPPreserveNewline />", $matches[0]); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -723,20 +723,20 @@ discard block |
||
| 723 | 723 | * @param string $pee The content. |
| 724 | 724 | * @return string The filtered content. |
| 725 | 725 | */ |
| 726 | -function shortcode_unautop( $pee ) { |
|
| 726 | +function shortcode_unautop($pee) { |
|
| 727 | 727 | global $shortcode_tags; |
| 728 | 728 | |
| 729 | - if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) { |
|
| 729 | + if (empty($shortcode_tags) || ! is_array($shortcode_tags)) { |
|
| 730 | 730 | return $pee; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | - $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); |
|
| 733 | + $tagregexp = join('|', array_map('preg_quote', array_keys($shortcode_tags))); |
|
| 734 | 734 | $spaces = wp_spaces_regexp(); |
| 735 | 735 | |
| 736 | 736 | $pattern = |
| 737 | 737 | '/' |
| 738 | 738 | . '<p>' // Opening paragraph |
| 739 | - . '(?:' . $spaces . ')*+' // Optional leading whitespace |
|
| 739 | + . '(?:'.$spaces.')*+' // Optional leading whitespace |
|
| 740 | 740 | . '(' // 1: The shortcode |
| 741 | 741 | . '\\[' // Opening bracket |
| 742 | 742 | . "($tagregexp)" // 2: Shortcode name |
@@ -761,11 +761,11 @@ discard block |
||
| 761 | 761 | . ')?' |
| 762 | 762 | . ')' |
| 763 | 763 | . ')' |
| 764 | - . '(?:' . $spaces . ')*+' // optional trailing whitespace |
|
| 764 | + . '(?:'.$spaces.')*+' // optional trailing whitespace |
|
| 765 | 765 | . '<\\/p>' // closing paragraph |
| 766 | 766 | . '/s'; |
| 767 | 767 | |
| 768 | - return preg_replace( $pattern, '$1', $pee ); |
|
| 768 | + return preg_replace($pattern, '$1', $pee); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -780,20 +780,20 @@ discard block |
||
| 780 | 780 | * @param string $str The string to be checked |
| 781 | 781 | * @return bool True if $str fits a UTF-8 model, false otherwise. |
| 782 | 782 | */ |
| 783 | -function seems_utf8( $str ) { |
|
| 783 | +function seems_utf8($str) { |
|
| 784 | 784 | mbstring_binary_safe_encoding(); |
| 785 | 785 | $length = strlen($str); |
| 786 | 786 | reset_mbstring_encoding(); |
| 787 | - for ($i=0; $i < $length; $i++) { |
|
| 787 | + for ($i = 0; $i < $length; $i++) { |
|
| 788 | 788 | $c = ord($str[$i]); |
| 789 | 789 | if ($c < 0x80) $n = 0; // 0bbbbbbb |
| 790 | - elseif (($c & 0xE0) == 0xC0) $n=1; // 110bbbbb |
|
| 791 | - elseif (($c & 0xF0) == 0xE0) $n=2; // 1110bbbb |
|
| 792 | - elseif (($c & 0xF8) == 0xF0) $n=3; // 11110bbb |
|
| 793 | - elseif (($c & 0xFC) == 0xF8) $n=4; // 111110bb |
|
| 794 | - elseif (($c & 0xFE) == 0xFC) $n=5; // 1111110b |
|
| 790 | + elseif (($c & 0xE0) == 0xC0) $n = 1; // 110bbbbb |
|
| 791 | + elseif (($c & 0xF0) == 0xE0) $n = 2; // 1110bbbb |
|
| 792 | + elseif (($c & 0xF8) == 0xF0) $n = 3; // 11110bbb |
|
| 793 | + elseif (($c & 0xFC) == 0xF8) $n = 4; // 111110bb |
|
| 794 | + elseif (($c & 0xFE) == 0xFC) $n = 5; // 1111110b |
|
| 795 | 795 | else return false; // Does not match any model |
| 796 | - for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? |
|
| 796 | + for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ? |
|
| 797 | 797 | if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) |
| 798 | 798 | return false; |
| 799 | 799 | } |
@@ -820,55 +820,55 @@ discard block |
||
| 820 | 820 | * @param bool $double_encode Optional. Whether to encode existing html entities. Default is false. |
| 821 | 821 | * @return string The encoded text with HTML entities. |
| 822 | 822 | */ |
| 823 | -function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
|
| 823 | +function _wp_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { |
|
| 824 | 824 | $string = (string) $string; |
| 825 | 825 | |
| 826 | - if ( 0 === strlen( $string ) ) |
|
| 826 | + if (0 === strlen($string)) |
|
| 827 | 827 | return ''; |
| 828 | 828 | |
| 829 | 829 | // Don't bother if there are no specialchars - saves some processing |
| 830 | - if ( ! preg_match( '/[&<>"\']/', $string ) ) |
|
| 830 | + if ( ! preg_match('/[&<>"\']/', $string)) |
|
| 831 | 831 | return $string; |
| 832 | 832 | |
| 833 | 833 | // Account for the previous behaviour of the function when the $quote_style is not an accepted value |
| 834 | - if ( empty( $quote_style ) ) |
|
| 834 | + if (empty($quote_style)) |
|
| 835 | 835 | $quote_style = ENT_NOQUOTES; |
| 836 | - elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) |
|
| 836 | + elseif ( ! in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) |
|
| 837 | 837 | $quote_style = ENT_QUOTES; |
| 838 | 838 | |
| 839 | 839 | // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() |
| 840 | - if ( ! $charset ) { |
|
| 840 | + if ( ! $charset) { |
|
| 841 | 841 | static $_charset = null; |
| 842 | - if ( ! isset( $_charset ) ) { |
|
| 842 | + if ( ! isset($_charset)) { |
|
| 843 | 843 | $alloptions = wp_load_alloptions(); |
| 844 | - $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; |
|
| 844 | + $_charset = isset($alloptions['blog_charset']) ? $alloptions['blog_charset'] : ''; |
|
| 845 | 845 | } |
| 846 | 846 | $charset = $_charset; |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) |
|
| 849 | + if (in_array($charset, array('utf8', 'utf-8', 'UTF8'))) |
|
| 850 | 850 | $charset = 'UTF-8'; |
| 851 | 851 | |
| 852 | 852 | $_quote_style = $quote_style; |
| 853 | 853 | |
| 854 | - if ( $quote_style === 'double' ) { |
|
| 854 | + if ($quote_style === 'double') { |
|
| 855 | 855 | $quote_style = ENT_COMPAT; |
| 856 | 856 | $_quote_style = ENT_COMPAT; |
| 857 | - } elseif ( $quote_style === 'single' ) { |
|
| 857 | + } elseif ($quote_style === 'single') { |
|
| 858 | 858 | $quote_style = ENT_NOQUOTES; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | - if ( ! $double_encode ) { |
|
| 861 | + if ( ! $double_encode) { |
|
| 862 | 862 | // Guarantee every &entity; is valid, convert &garbage; into &garbage; |
| 863 | 863 | // This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable. |
| 864 | - $string = wp_kses_normalize_entities( $string ); |
|
| 864 | + $string = wp_kses_normalize_entities($string); |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - $string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode ); |
|
| 867 | + $string = @htmlspecialchars($string, $quote_style, $charset, $double_encode); |
|
| 868 | 868 | |
| 869 | 869 | // Backwards compatibility |
| 870 | - if ( 'single' === $_quote_style ) |
|
| 871 | - $string = str_replace( "'", ''', $string ); |
|
| 870 | + if ('single' === $_quote_style) |
|
| 871 | + $string = str_replace("'", ''', $string); |
|
| 872 | 872 | |
| 873 | 873 | return $string; |
| 874 | 874 | } |
@@ -893,52 +893,52 @@ discard block |
||
| 893 | 893 | * Default is ENT_NOQUOTES. |
| 894 | 894 | * @return string The decoded text without HTML entities. |
| 895 | 895 | */ |
| 896 | -function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { |
|
| 896 | +function wp_specialchars_decode($string, $quote_style = ENT_NOQUOTES) { |
|
| 897 | 897 | $string = (string) $string; |
| 898 | 898 | |
| 899 | - if ( 0 === strlen( $string ) ) { |
|
| 899 | + if (0 === strlen($string)) { |
|
| 900 | 900 | return ''; |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | // Don't bother if there are no entities - saves a lot of processing |
| 904 | - if ( strpos( $string, '&' ) === false ) { |
|
| 904 | + if (strpos($string, '&') === false) { |
|
| 905 | 905 | return $string; |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | // Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value |
| 909 | - if ( empty( $quote_style ) ) { |
|
| 909 | + if (empty($quote_style)) { |
|
| 910 | 910 | $quote_style = ENT_NOQUOTES; |
| 911 | - } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { |
|
| 911 | + } elseif ( ! in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) { |
|
| 912 | 912 | $quote_style = ENT_QUOTES; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | // More complete than get_html_translation_table( HTML_SPECIALCHARS ) |
| 916 | - $single = array( ''' => '\'', ''' => '\'' ); |
|
| 917 | - $single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' ); |
|
| 918 | - $double = array( '"' => '"', '"' => '"', '"' => '"' ); |
|
| 919 | - $double_preg = array( '/�*34;/' => '"', '/�*22;/i' => '"' ); |
|
| 920 | - $others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' ); |
|
| 921 | - $others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' ); |
|
| 922 | - |
|
| 923 | - if ( $quote_style === ENT_QUOTES ) { |
|
| 924 | - $translation = array_merge( $single, $double, $others ); |
|
| 925 | - $translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); |
|
| 926 | - } elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) { |
|
| 927 | - $translation = array_merge( $double, $others ); |
|
| 928 | - $translation_preg = array_merge( $double_preg, $others_preg ); |
|
| 929 | - } elseif ( $quote_style === 'single' ) { |
|
| 930 | - $translation = array_merge( $single, $others ); |
|
| 931 | - $translation_preg = array_merge( $single_preg, $others_preg ); |
|
| 932 | - } elseif ( $quote_style === ENT_NOQUOTES ) { |
|
| 916 | + $single = array(''' => '\'', ''' => '\''); |
|
| 917 | + $single_preg = array('/�*39;/' => ''', '/�*27;/i' => '''); |
|
| 918 | + $double = array('"' => '"', '"' => '"', '"' => '"'); |
|
| 919 | + $double_preg = array('/�*34;/' => '"', '/�*22;/i' => '"'); |
|
| 920 | + $others = array('<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&'); |
|
| 921 | + $others_preg = array('/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&'); |
|
| 922 | + |
|
| 923 | + if ($quote_style === ENT_QUOTES) { |
|
| 924 | + $translation = array_merge($single, $double, $others); |
|
| 925 | + $translation_preg = array_merge($single_preg, $double_preg, $others_preg); |
|
| 926 | + } elseif ($quote_style === ENT_COMPAT || $quote_style === 'double') { |
|
| 927 | + $translation = array_merge($double, $others); |
|
| 928 | + $translation_preg = array_merge($double_preg, $others_preg); |
|
| 929 | + } elseif ($quote_style === 'single') { |
|
| 930 | + $translation = array_merge($single, $others); |
|
| 931 | + $translation_preg = array_merge($single_preg, $others_preg); |
|
| 932 | + } elseif ($quote_style === ENT_NOQUOTES) { |
|
| 933 | 933 | $translation = $others; |
| 934 | 934 | $translation_preg = $others_preg; |
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | // Remove zero padding on numeric entities |
| 938 | - $string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string ); |
|
| 938 | + $string = preg_replace(array_keys($translation_preg), array_values($translation_preg), $string); |
|
| 939 | 939 | |
| 940 | 940 | // Replace characters according to translation table |
| 941 | - return strtr( $string, $translation ); |
|
| 941 | + return strtr($string, $translation); |
|
| 942 | 942 | } |
| 943 | 943 | |
| 944 | 944 | /** |
@@ -953,40 +953,40 @@ discard block |
||
| 953 | 953 | * @param bool $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false. |
| 954 | 954 | * @return string The checked text. |
| 955 | 955 | */ |
| 956 | -function wp_check_invalid_utf8( $string, $strip = false ) { |
|
| 956 | +function wp_check_invalid_utf8($string, $strip = false) { |
|
| 957 | 957 | $string = (string) $string; |
| 958 | 958 | |
| 959 | - if ( 0 === strlen( $string ) ) { |
|
| 959 | + if (0 === strlen($string)) { |
|
| 960 | 960 | return ''; |
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | // Store the site charset as a static to avoid multiple calls to get_option() |
| 964 | 964 | static $is_utf8 = null; |
| 965 | - if ( ! isset( $is_utf8 ) ) { |
|
| 966 | - $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); |
|
| 965 | + if ( ! isset($is_utf8)) { |
|
| 966 | + $is_utf8 = in_array(get_option('blog_charset'), array('utf8', 'utf-8', 'UTF8', 'UTF-8')); |
|
| 967 | 967 | } |
| 968 | - if ( ! $is_utf8 ) { |
|
| 968 | + if ( ! $is_utf8) { |
|
| 969 | 969 | return $string; |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | // Check for support for utf8 in the installed PCRE library once and store the result in a static |
| 973 | 973 | static $utf8_pcre = null; |
| 974 | - if ( ! isset( $utf8_pcre ) ) { |
|
| 975 | - $utf8_pcre = @preg_match( '/^./u', 'a' ); |
|
| 974 | + if ( ! isset($utf8_pcre)) { |
|
| 975 | + $utf8_pcre = @preg_match('/^./u', 'a'); |
|
| 976 | 976 | } |
| 977 | 977 | // We can't demand utf8 in the PCRE installation, so just return the string in those cases |
| 978 | - if ( !$utf8_pcre ) { |
|
| 978 | + if ( ! $utf8_pcre) { |
|
| 979 | 979 | return $string; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | // preg_match fails when it encounters invalid UTF8 in $string |
| 983 | - if ( 1 === @preg_match( '/^./us', $string ) ) { |
|
| 983 | + if (1 === @preg_match('/^./us', $string)) { |
|
| 984 | 984 | return $string; |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // Attempt to strip the bad chars if requested (not recommended) |
| 988 | - if ( $strip && function_exists( 'iconv' ) ) { |
|
| 989 | - return iconv( 'utf-8', 'utf-8', $string ); |
|
| 988 | + if ($strip && function_exists('iconv')) { |
|
| 989 | + return iconv('utf-8', 'utf-8', $string); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | return ''; |
@@ -1001,30 +1001,30 @@ discard block |
||
| 1001 | 1001 | * @param int $length Max length of the string |
| 1002 | 1002 | * @return string String with Unicode encoded for URI. |
| 1003 | 1003 | */ |
| 1004 | -function utf8_uri_encode( $utf8_string, $length = 0 ) { |
|
| 1004 | +function utf8_uri_encode($utf8_string, $length = 0) { |
|
| 1005 | 1005 | $unicode = ''; |
| 1006 | 1006 | $values = array(); |
| 1007 | 1007 | $num_octets = 1; |
| 1008 | 1008 | $unicode_length = 0; |
| 1009 | 1009 | |
| 1010 | 1010 | mbstring_binary_safe_encoding(); |
| 1011 | - $string_length = strlen( $utf8_string ); |
|
| 1011 | + $string_length = strlen($utf8_string); |
|
| 1012 | 1012 | reset_mbstring_encoding(); |
| 1013 | 1013 | |
| 1014 | - for ($i = 0; $i < $string_length; $i++ ) { |
|
| 1014 | + for ($i = 0; $i < $string_length; $i++) { |
|
| 1015 | 1015 | |
| 1016 | - $value = ord( $utf8_string[ $i ] ); |
|
| 1016 | + $value = ord($utf8_string[$i]); |
|
| 1017 | 1017 | |
| 1018 | - if ( $value < 128 ) { |
|
| 1019 | - if ( $length && ( $unicode_length >= $length ) ) |
|
| 1018 | + if ($value < 128) { |
|
| 1019 | + if ($length && ($unicode_length >= $length)) |
|
| 1020 | 1020 | break; |
| 1021 | 1021 | $unicode .= chr($value); |
| 1022 | 1022 | $unicode_length++; |
| 1023 | 1023 | } else { |
| 1024 | - if ( count( $values ) == 0 ) { |
|
| 1025 | - if ( $value < 224 ) { |
|
| 1024 | + if (count($values) == 0) { |
|
| 1025 | + if ($value < 224) { |
|
| 1026 | 1026 | $num_octets = 2; |
| 1027 | - } elseif ( $value < 240 ) { |
|
| 1027 | + } elseif ($value < 240) { |
|
| 1028 | 1028 | $num_octets = 3; |
| 1029 | 1029 | } else { |
| 1030 | 1030 | $num_octets = 4; |
@@ -1033,11 +1033,11 @@ discard block |
||
| 1033 | 1033 | |
| 1034 | 1034 | $values[] = $value; |
| 1035 | 1035 | |
| 1036 | - if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) |
|
| 1036 | + if ($length && ($unicode_length + ($num_octets * 3)) > $length) |
|
| 1037 | 1037 | break; |
| 1038 | - if ( count( $values ) == $num_octets ) { |
|
| 1039 | - for ( $j = 0; $j < $num_octets; $j++ ) { |
|
| 1040 | - $unicode .= '%' . dechex( $values[ $j ] ); |
|
| 1038 | + if (count($values) == $num_octets) { |
|
| 1039 | + for ($j = 0; $j < $num_octets; $j++) { |
|
| 1040 | + $unicode .= '%'.dechex($values[$j]); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | $unicode_length += $num_octets * 3; |
@@ -1061,8 +1061,8 @@ discard block |
||
| 1061 | 1061 | * @param string $string Text that might have accent characters |
| 1062 | 1062 | * @return string Filtered string with replaced "nice" characters. |
| 1063 | 1063 | */ |
| 1064 | -function remove_accents( $string ) { |
|
| 1065 | - if ( !preg_match('/[\x80-\xff]/', $string) ) |
|
| 1064 | +function remove_accents($string) { |
|
| 1065 | + if ( ! preg_match('/[\x80-\xff]/', $string)) |
|
| 1066 | 1066 | return $string; |
| 1067 | 1067 | |
| 1068 | 1068 | if (seems_utf8($string)) { |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
| 1073 | 1073 | chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', |
| 1074 | 1074 | chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', |
| 1075 | - chr(195).chr(134) => 'AE',chr(195).chr(135) => 'C', |
|
| 1075 | + chr(195).chr(134) => 'AE', chr(195).chr(135) => 'C', |
|
| 1076 | 1076 | chr(195).chr(136) => 'E', chr(195).chr(137) => 'E', |
| 1077 | 1077 | chr(195).chr(138) => 'E', chr(195).chr(139) => 'E', |
| 1078 | 1078 | chr(195).chr(140) => 'I', chr(195).chr(141) => 'I', |
@@ -1083,11 +1083,11 @@ discard block |
||
| 1083 | 1083 | chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', |
| 1084 | 1084 | chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', |
| 1085 | 1085 | chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', |
| 1086 | - chr(195).chr(158) => 'TH',chr(195).chr(159) => 's', |
|
| 1086 | + chr(195).chr(158) => 'TH', chr(195).chr(159) => 's', |
|
| 1087 | 1087 | chr(195).chr(160) => 'a', chr(195).chr(161) => 'a', |
| 1088 | 1088 | chr(195).chr(162) => 'a', chr(195).chr(163) => 'a', |
| 1089 | 1089 | chr(195).chr(164) => 'a', chr(195).chr(165) => 'a', |
| 1090 | - chr(195).chr(166) => 'ae',chr(195).chr(167) => 'c', |
|
| 1090 | + chr(195).chr(166) => 'ae', chr(195).chr(167) => 'c', |
|
| 1091 | 1091 | chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', |
| 1092 | 1092 | chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', |
| 1093 | 1093 | chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
| 1127 | 1127 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
| 1128 | 1128 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
| 1129 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 1129 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
| 1130 | 1130 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
| 1131 | 1131 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
| 1132 | 1132 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -1142,13 +1142,13 @@ discard block |
||
| 1142 | 1142 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
| 1143 | 1143 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
| 1144 | 1144 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
| 1145 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 1146 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 1147 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 1148 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 1149 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 1150 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 1151 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 1145 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
| 1146 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
| 1147 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
| 1148 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
| 1149 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
| 1150 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
| 1151 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
| 1152 | 1152 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
| 1153 | 1153 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
| 1154 | 1154 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -1245,21 +1245,21 @@ discard block |
||
| 1245 | 1245 | // Used for locale-specific rules |
| 1246 | 1246 | $locale = get_locale(); |
| 1247 | 1247 | |
| 1248 | - if ( 'de_DE' == $locale || 'de_DE_formal' == $locale ) { |
|
| 1249 | - $chars[ chr(195).chr(132) ] = 'Ae'; |
|
| 1250 | - $chars[ chr(195).chr(164) ] = 'ae'; |
|
| 1251 | - $chars[ chr(195).chr(150) ] = 'Oe'; |
|
| 1252 | - $chars[ chr(195).chr(182) ] = 'oe'; |
|
| 1253 | - $chars[ chr(195).chr(156) ] = 'Ue'; |
|
| 1254 | - $chars[ chr(195).chr(188) ] = 'ue'; |
|
| 1255 | - $chars[ chr(195).chr(159) ] = 'ss'; |
|
| 1256 | - } elseif ( 'da_DK' === $locale ) { |
|
| 1257 | - $chars[ chr(195).chr(134) ] = 'Ae'; |
|
| 1258 | - $chars[ chr(195).chr(166) ] = 'ae'; |
|
| 1259 | - $chars[ chr(195).chr(152) ] = 'Oe'; |
|
| 1260 | - $chars[ chr(195).chr(184) ] = 'oe'; |
|
| 1261 | - $chars[ chr(195).chr(133) ] = 'Aa'; |
|
| 1262 | - $chars[ chr(195).chr(165) ] = 'aa'; |
|
| 1248 | + if ('de_DE' == $locale || 'de_DE_formal' == $locale) { |
|
| 1249 | + $chars[chr(195).chr(132)] = 'Ae'; |
|
| 1250 | + $chars[chr(195).chr(164)] = 'ae'; |
|
| 1251 | + $chars[chr(195).chr(150)] = 'Oe'; |
|
| 1252 | + $chars[chr(195).chr(182)] = 'oe'; |
|
| 1253 | + $chars[chr(195).chr(156)] = 'Ue'; |
|
| 1254 | + $chars[chr(195).chr(188)] = 'ue'; |
|
| 1255 | + $chars[chr(195).chr(159)] = 'ss'; |
|
| 1256 | + } elseif ('da_DK' === $locale) { |
|
| 1257 | + $chars[chr(195).chr(134)] = 'Ae'; |
|
| 1258 | + $chars[chr(195).chr(166)] = 'ae'; |
|
| 1259 | + $chars[chr(195).chr(152)] = 'Oe'; |
|
| 1260 | + $chars[chr(195).chr(184)] = 'oe'; |
|
| 1261 | + $chars[chr(195).chr(133)] = 'Aa'; |
|
| 1262 | + $chars[chr(195).chr(165)] = 'aa'; |
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | $string = strtr($string, $chars); |
@@ -1303,7 +1303,7 @@ discard block |
||
| 1303 | 1303 | * @param string $filename The filename to be sanitized |
| 1304 | 1304 | * @return string The sanitized filename |
| 1305 | 1305 | */ |
| 1306 | -function sanitize_file_name( $filename ) { |
|
| 1306 | +function sanitize_file_name($filename) { |
|
| 1307 | 1307 | $filename_raw = $filename; |
| 1308 | 1308 | $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0)); |
| 1309 | 1309 | /** |
@@ -1314,18 +1314,18 @@ discard block |
||
| 1314 | 1314 | * @param array $special_chars Characters to remove. |
| 1315 | 1315 | * @param string $filename_raw Filename as it was passed into sanitize_file_name(). |
| 1316 | 1316 | */ |
| 1317 | - $special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw ); |
|
| 1318 | - $filename = preg_replace( "#\x{00a0}#siu", ' ', $filename ); |
|
| 1319 | - $filename = str_replace( $special_chars, '', $filename ); |
|
| 1320 | - $filename = str_replace( array( '%20', '+' ), '-', $filename ); |
|
| 1321 | - $filename = preg_replace( '/[\r\n\t -]+/', '-', $filename ); |
|
| 1322 | - $filename = trim( $filename, '.-_' ); |
|
| 1317 | + $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw); |
|
| 1318 | + $filename = preg_replace("#\x{00a0}#siu", ' ', $filename); |
|
| 1319 | + $filename = str_replace($special_chars, '', $filename); |
|
| 1320 | + $filename = str_replace(array('%20', '+'), '-', $filename); |
|
| 1321 | + $filename = preg_replace('/[\r\n\t -]+/', '-', $filename); |
|
| 1322 | + $filename = trim($filename, '.-_'); |
|
| 1323 | 1323 | |
| 1324 | 1324 | // Split the filename into a base and extension[s] |
| 1325 | 1325 | $parts = explode('.', $filename); |
| 1326 | 1326 | |
| 1327 | 1327 | // Return if only one extension |
| 1328 | - if ( count( $parts ) <= 2 ) { |
|
| 1328 | + if (count($parts) <= 2) { |
|
| 1329 | 1329 | /** |
| 1330 | 1330 | * Filter a sanitized filename string. |
| 1331 | 1331 | * |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | * @param string $filename Sanitized filename. |
| 1335 | 1335 | * @param string $filename_raw The filename prior to sanitization. |
| 1336 | 1336 | */ |
| 1337 | - return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); |
|
| 1337 | + return apply_filters('sanitize_file_name', $filename, $filename_raw); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | // Process multiple extensions |
@@ -1346,23 +1346,23 @@ discard block |
||
| 1346 | 1346 | * Loop over any intermediate extensions. Postfix them with a trailing underscore |
| 1347 | 1347 | * if they are a 2 - 5 character long alpha string not in the extension whitelist. |
| 1348 | 1348 | */ |
| 1349 | - foreach ( (array) $parts as $part) { |
|
| 1350 | - $filename .= '.' . $part; |
|
| 1349 | + foreach ((array) $parts as $part) { |
|
| 1350 | + $filename .= '.'.$part; |
|
| 1351 | 1351 | |
| 1352 | - if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) { |
|
| 1352 | + if (preg_match("/^[a-zA-Z]{2,5}\d?$/", $part)) { |
|
| 1353 | 1353 | $allowed = false; |
| 1354 | - foreach ( $mimes as $ext_preg => $mime_match ) { |
|
| 1355 | - $ext_preg = '!^(' . $ext_preg . ')$!i'; |
|
| 1356 | - if ( preg_match( $ext_preg, $part ) ) { |
|
| 1354 | + foreach ($mimes as $ext_preg => $mime_match) { |
|
| 1355 | + $ext_preg = '!^('.$ext_preg.')$!i'; |
|
| 1356 | + if (preg_match($ext_preg, $part)) { |
|
| 1357 | 1357 | $allowed = true; |
| 1358 | 1358 | break; |
| 1359 | 1359 | } |
| 1360 | 1360 | } |
| 1361 | - if ( !$allowed ) |
|
| 1361 | + if ( ! $allowed) |
|
| 1362 | 1362 | $filename .= '_'; |
| 1363 | 1363 | } |
| 1364 | 1364 | } |
| 1365 | - $filename .= '.' . $extension; |
|
| 1365 | + $filename .= '.'.$extension; |
|
| 1366 | 1366 | /** This filter is documented in wp-includes/formatting.php */ |
| 1367 | 1367 | return apply_filters('sanitize_file_name', $filename, $filename_raw); |
| 1368 | 1368 | } |
@@ -1381,21 +1381,21 @@ discard block |
||
| 1381 | 1381 | * @param bool $strict If set limits $username to specific characters. Default false. |
| 1382 | 1382 | * @return string The sanitized username, after passing through filters. |
| 1383 | 1383 | */ |
| 1384 | -function sanitize_user( $username, $strict = false ) { |
|
| 1384 | +function sanitize_user($username, $strict = false) { |
|
| 1385 | 1385 | $raw_username = $username; |
| 1386 | - $username = wp_strip_all_tags( $username ); |
|
| 1387 | - $username = remove_accents( $username ); |
|
| 1386 | + $username = wp_strip_all_tags($username); |
|
| 1387 | + $username = remove_accents($username); |
|
| 1388 | 1388 | // Kill octets |
| 1389 | - $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); |
|
| 1390 | - $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities |
|
| 1389 | + $username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $username); |
|
| 1390 | + $username = preg_replace('/&.+?;/', '', $username); // Kill entities |
|
| 1391 | 1391 | |
| 1392 | 1392 | // If strict, reduce to ASCII for max portability. |
| 1393 | - if ( $strict ) |
|
| 1394 | - $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); |
|
| 1393 | + if ($strict) |
|
| 1394 | + $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username); |
|
| 1395 | 1395 | |
| 1396 | - $username = trim( $username ); |
|
| 1396 | + $username = trim($username); |
|
| 1397 | 1397 | // Consolidate contiguous whitespace |
| 1398 | - $username = preg_replace( '|\s+|', ' ', $username ); |
|
| 1398 | + $username = preg_replace('|\s+|', ' ', $username); |
|
| 1399 | 1399 | |
| 1400 | 1400 | /** |
| 1401 | 1401 | * Filter a sanitized username string. |
@@ -1406,7 +1406,7 @@ discard block |
||
| 1406 | 1406 | * @param string $raw_username The username prior to sanitization. |
| 1407 | 1407 | * @param bool $strict Whether to limit the sanitization to specific characters. Default false. |
| 1408 | 1408 | */ |
| 1409 | - return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); |
|
| 1409 | + return apply_filters('sanitize_user', $username, $raw_username, $strict); |
|
| 1410 | 1410 | } |
| 1411 | 1411 | |
| 1412 | 1412 | /** |
@@ -1419,10 +1419,10 @@ discard block |
||
| 1419 | 1419 | * @param string $key String key |
| 1420 | 1420 | * @return string Sanitized key |
| 1421 | 1421 | */ |
| 1422 | -function sanitize_key( $key ) { |
|
| 1422 | +function sanitize_key($key) { |
|
| 1423 | 1423 | $raw_key = $key; |
| 1424 | - $key = strtolower( $key ); |
|
| 1425 | - $key = preg_replace( '/[^a-z0-9_\-]/', '', $key ); |
|
| 1424 | + $key = strtolower($key); |
|
| 1425 | + $key = preg_replace('/[^a-z0-9_\-]/', '', $key); |
|
| 1426 | 1426 | |
| 1427 | 1427 | /** |
| 1428 | 1428 | * Filter a sanitized key string. |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | * @param string $key Sanitized key. |
| 1433 | 1433 | * @param string $raw_key The key prior to sanitization. |
| 1434 | 1434 | */ |
| 1435 | - return apply_filters( 'sanitize_key', $key, $raw_key ); |
|
| 1435 | + return apply_filters('sanitize_key', $key, $raw_key); |
|
| 1436 | 1436 | } |
| 1437 | 1437 | |
| 1438 | 1438 | /** |
@@ -1449,10 +1449,10 @@ discard block |
||
| 1449 | 1449 | * @param string $context Optional. The operation for which the string is sanitized |
| 1450 | 1450 | * @return string The sanitized string. |
| 1451 | 1451 | */ |
| 1452 | -function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { |
|
| 1452 | +function sanitize_title($title, $fallback_title = '', $context = 'save') { |
|
| 1453 | 1453 | $raw_title = $title; |
| 1454 | 1454 | |
| 1455 | - if ( 'save' == $context ) |
|
| 1455 | + if ('save' == $context) |
|
| 1456 | 1456 | $title = remove_accents($title); |
| 1457 | 1457 | |
| 1458 | 1458 | /** |
@@ -1464,9 +1464,9 @@ discard block |
||
| 1464 | 1464 | * @param string $raw_title The title prior to sanitization. |
| 1465 | 1465 | * @param string $context The context for which the title is being sanitized. |
| 1466 | 1466 | */ |
| 1467 | - $title = apply_filters( 'sanitize_title', $title, $raw_title, $context ); |
|
| 1467 | + $title = apply_filters('sanitize_title', $title, $raw_title, $context); |
|
| 1468 | 1468 | |
| 1469 | - if ( '' === $title || false === $title ) |
|
| 1469 | + if ('' === $title || false === $title) |
|
| 1470 | 1470 | $title = $fallback_title; |
| 1471 | 1471 | |
| 1472 | 1472 | return $title; |
@@ -1482,8 +1482,8 @@ discard block |
||
| 1482 | 1482 | * @param string $title The string to be sanitized. |
| 1483 | 1483 | * @return string The sanitized string. |
| 1484 | 1484 | */ |
| 1485 | -function sanitize_title_for_query( $title ) { |
|
| 1486 | - return sanitize_title( $title, '', 'query' ); |
|
| 1485 | +function sanitize_title_for_query($title) { |
|
| 1486 | + return sanitize_title($title, '', 'query'); |
|
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | 1489 | /** |
@@ -1499,7 +1499,7 @@ discard block |
||
| 1499 | 1499 | * @param string $context Optional. The operation for which the string is sanitized. |
| 1500 | 1500 | * @return string The sanitized title. |
| 1501 | 1501 | */ |
| 1502 | -function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) { |
|
| 1502 | +function sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') { |
|
| 1503 | 1503 | $title = strip_tags($title); |
| 1504 | 1504 | // Preserve escaped octets. |
| 1505 | 1505 | $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); |
@@ -1519,12 +1519,12 @@ discard block |
||
| 1519 | 1519 | $title = preg_replace('/&.+?;/', '', $title); // kill entities |
| 1520 | 1520 | $title = str_replace('.', '-', $title); |
| 1521 | 1521 | |
| 1522 | - if ( 'save' == $context ) { |
|
| 1522 | + if ('save' == $context) { |
|
| 1523 | 1523 | // Convert nbsp, ndash and mdash to hyphens |
| 1524 | - $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); |
|
| 1524 | + $title = str_replace(array('%c2%a0', '%e2%80%93', '%e2%80%94'), '-', $title); |
|
| 1525 | 1525 | |
| 1526 | 1526 | // Strip these characters entirely |
| 1527 | - $title = str_replace( array( |
|
| 1527 | + $title = str_replace(array( |
|
| 1528 | 1528 | // iexcl and iquest |
| 1529 | 1529 | '%c2%a1', '%c2%bf', |
| 1530 | 1530 | // angle quotes |
@@ -1538,10 +1538,10 @@ discard block |
||
| 1538 | 1538 | '%c2%b4', '%cb%8a', '%cc%81', '%cd%81', |
| 1539 | 1539 | // grave accent, macron, caron |
| 1540 | 1540 | '%cc%80', '%cc%84', '%cc%8c', |
| 1541 | - ), '', $title ); |
|
| 1541 | + ), '', $title); |
|
| 1542 | 1542 | |
| 1543 | 1543 | // Convert times to x |
| 1544 | - $title = str_replace( '%c3%97', 'x', $title ); |
|
| 1544 | + $title = str_replace('%c3%97', 'x', $title); |
|
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); |
@@ -1565,8 +1565,8 @@ discard block |
||
| 1565 | 1565 | * @param string $orderby Order by clause to be validated. |
| 1566 | 1566 | * @return string|false Returns $orderby if valid, false otherwise. |
| 1567 | 1567 | */ |
| 1568 | -function sanitize_sql_orderby( $orderby ) { |
|
| 1569 | - if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) { |
|
| 1568 | +function sanitize_sql_orderby($orderby) { |
|
| 1569 | + if (preg_match('/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby) || preg_match('/^\s*RAND\(\s*\)\s*$/i', $orderby)) { |
|
| 1570 | 1570 | return $orderby; |
| 1571 | 1571 | } |
| 1572 | 1572 | return false; |
@@ -1587,14 +1587,14 @@ discard block |
||
| 1587 | 1587 | * Defaults to an empty string. |
| 1588 | 1588 | * @return string The sanitized value |
| 1589 | 1589 | */ |
| 1590 | -function sanitize_html_class( $class, $fallback = '' ) { |
|
| 1590 | +function sanitize_html_class($class, $fallback = '') { |
|
| 1591 | 1591 | //Strip out any % encoded octets |
| 1592 | - $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); |
|
| 1592 | + $sanitized = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $class); |
|
| 1593 | 1593 | |
| 1594 | 1594 | //Limit to A-Z,a-z,0-9,_,- |
| 1595 | - $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); |
|
| 1595 | + $sanitized = preg_replace('/[^A-Za-z0-9_-]/', '', $sanitized); |
|
| 1596 | 1596 | |
| 1597 | - if ( '' == $sanitized ) |
|
| 1597 | + if ('' == $sanitized) |
|
| 1598 | 1598 | $sanitized = $fallback; |
| 1599 | 1599 | |
| 1600 | 1600 | /** |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | * @param string $class HTML class before sanitization. |
| 1607 | 1607 | * @param string $fallback The fallback string. |
| 1608 | 1608 | */ |
| 1609 | - return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback ); |
|
| 1609 | + return apply_filters('sanitize_html_class', $sanitized, $class, $fallback); |
|
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | 1612 | /** |
@@ -1618,13 +1618,13 @@ discard block |
||
| 1618 | 1618 | * @param string $deprecated Not used. |
| 1619 | 1619 | * @return string Converted string. |
| 1620 | 1620 | */ |
| 1621 | -function convert_chars( $content, $deprecated = '' ) { |
|
| 1622 | - if ( ! empty( $deprecated ) ) { |
|
| 1623 | - _deprecated_argument( __FUNCTION__, '0.71' ); |
|
| 1621 | +function convert_chars($content, $deprecated = '') { |
|
| 1622 | + if ( ! empty($deprecated)) { |
|
| 1623 | + _deprecated_argument(__FUNCTION__, '0.71'); |
|
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | - if ( strpos( $content, '&' ) !== false ) { |
|
| 1627 | - $content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content ); |
|
| 1626 | + if (strpos($content, '&') !== false) { |
|
| 1627 | + $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | return $content; |
@@ -1638,12 +1638,12 @@ discard block |
||
| 1638 | 1638 | * @param string $content String with entities that need converting. |
| 1639 | 1639 | * @return string Converted string. |
| 1640 | 1640 | */ |
| 1641 | -function convert_invalid_entities( $content ) { |
|
| 1641 | +function convert_invalid_entities($content) { |
|
| 1642 | 1642 | $wp_htmltranswinuni = array( |
| 1643 | 1643 | '€' => '€', // the Euro sign |
| 1644 | 1644 | '' => '', |
| 1645 | 1645 | '‚' => '‚', // these are Windows CP1252 specific characters |
| 1646 | - 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers |
|
| 1646 | + 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers |
|
| 1647 | 1647 | '„' => '„', |
| 1648 | 1648 | '…' => '…', |
| 1649 | 1649 | '†' => '†', |
@@ -1674,8 +1674,8 @@ discard block |
||
| 1674 | 1674 | 'Ÿ' => 'Ÿ' |
| 1675 | 1675 | ); |
| 1676 | 1676 | |
| 1677 | - if ( strpos( $content, '' ) !== false ) { |
|
| 1678 | - $content = strtr( $content, $wp_htmltranswinuni ); |
|
| 1677 | + if (strpos($content, '') !== false) { |
|
| 1678 | + $content = strtr($content, $wp_htmltranswinuni); |
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | return $content; |
@@ -1690,9 +1690,9 @@ discard block |
||
| 1690 | 1690 | * @param bool $force If true, forces balancing, ignoring the value of the option. Default false. |
| 1691 | 1691 | * @return string Balanced text |
| 1692 | 1692 | */ |
| 1693 | -function balanceTags( $text, $force = false ) { |
|
| 1694 | - if ( $force || get_option('use_balanceTags') == 1 ) { |
|
| 1695 | - return force_balance_tags( $text ); |
|
| 1693 | +function balanceTags($text, $force = false) { |
|
| 1694 | + if ($force || get_option('use_balanceTags') == 1) { |
|
| 1695 | + return force_balance_tags($text); |
|
| 1696 | 1696 | } else { |
| 1697 | 1697 | return $text; |
| 1698 | 1698 | } |
@@ -1716,22 +1716,22 @@ discard block |
||
| 1716 | 1716 | * @param string $text Text to be balanced. |
| 1717 | 1717 | * @return string Balanced text. |
| 1718 | 1718 | */ |
| 1719 | -function force_balance_tags( $text ) { |
|
| 1719 | +function force_balance_tags($text) { |
|
| 1720 | 1720 | $tagstack = array(); |
| 1721 | 1721 | $stacksize = 0; |
| 1722 | 1722 | $tagqueue = ''; |
| 1723 | 1723 | $newtext = ''; |
| 1724 | 1724 | // Known single-entity/self-closing tags |
| 1725 | - $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' ); |
|
| 1725 | + $single_tags = array('area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source'); |
|
| 1726 | 1726 | // Tags that can be immediately nested within themselves |
| 1727 | - $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); |
|
| 1727 | + $nestable_tags = array('blockquote', 'div', 'object', 'q', 'span'); |
|
| 1728 | 1728 | |
| 1729 | 1729 | // WP bug fix for comments - in case you REALLY meant to type '< !--' |
| 1730 | 1730 | $text = str_replace('< !--', '< !--', $text); |
| 1731 | 1731 | // WP bug fix for LOVE <3 (and other situations with '<' before a number) |
| 1732 | 1732 | $text = preg_replace('#<([0-9]{1})#', '<$1', $text); |
| 1733 | 1733 | |
| 1734 | - while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) { |
|
| 1734 | + while (preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex)) { |
|
| 1735 | 1735 | $newtext .= $tagqueue; |
| 1736 | 1736 | |
| 1737 | 1737 | $i = strpos($text, $regex[0]); |
@@ -1740,25 +1740,25 @@ discard block |
||
| 1740 | 1740 | // clear the shifter |
| 1741 | 1741 | $tagqueue = ''; |
| 1742 | 1742 | // Pop or Push |
| 1743 | - if ( isset($regex[1][0]) && '/' == $regex[1][0] ) { // End Tag |
|
| 1744 | - $tag = strtolower(substr($regex[1],1)); |
|
| 1743 | + if (isset($regex[1][0]) && '/' == $regex[1][0]) { // End Tag |
|
| 1744 | + $tag = strtolower(substr($regex[1], 1)); |
|
| 1745 | 1745 | // if too many closing tags |
| 1746 | - if ( $stacksize <= 0 ) { |
|
| 1746 | + if ($stacksize <= 0) { |
|
| 1747 | 1747 | $tag = ''; |
| 1748 | 1748 | // or close to be safe $tag = '/' . $tag; |
| 1749 | 1749 | } |
| 1750 | 1750 | // if stacktop value = tag close value then pop |
| 1751 | - elseif ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag |
|
| 1752 | - $tag = '</' . $tag . '>'; // Close Tag |
|
| 1751 | + elseif ($tagstack[$stacksize - 1] == $tag) { // found closing tag |
|
| 1752 | + $tag = '</'.$tag.'>'; // Close Tag |
|
| 1753 | 1753 | // Pop |
| 1754 | - array_pop( $tagstack ); |
|
| 1754 | + array_pop($tagstack); |
|
| 1755 | 1755 | $stacksize--; |
| 1756 | 1756 | } else { // closing tag not at top, search for it |
| 1757 | - for ( $j = $stacksize-1; $j >= 0; $j-- ) { |
|
| 1758 | - if ( $tagstack[$j] == $tag ) { |
|
| 1757 | + for ($j = $stacksize - 1; $j >= 0; $j--) { |
|
| 1758 | + if ($tagstack[$j] == $tag) { |
|
| 1759 | 1759 | // add tag to tagqueue |
| 1760 | - for ( $k = $stacksize-1; $k >= $j; $k--) { |
|
| 1761 | - $tagqueue .= '</' . array_pop( $tagstack ) . '>'; |
|
| 1760 | + for ($k = $stacksize - 1; $k >= $j; $k--) { |
|
| 1761 | + $tagqueue .= '</'.array_pop($tagstack).'>'; |
|
| 1762 | 1762 | $stacksize--; |
| 1763 | 1763 | } |
| 1764 | 1764 | break; |
@@ -1772,43 +1772,43 @@ discard block |
||
| 1772 | 1772 | // Tag Cleaning |
| 1773 | 1773 | |
| 1774 | 1774 | // If it's an empty tag "< >", do nothing |
| 1775 | - if ( '' == $tag ) { |
|
| 1775 | + if ('' == $tag) { |
|
| 1776 | 1776 | // do nothing |
| 1777 | 1777 | } |
| 1778 | 1778 | // ElseIf it presents itself as a self-closing tag... |
| 1779 | - elseif ( substr( $regex[2], -1 ) == '/' ) { |
|
| 1779 | + elseif (substr($regex[2], -1) == '/') { |
|
| 1780 | 1780 | // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and |
| 1781 | 1781 | // immediately close it with a closing tag (the tag will encapsulate no text as a result) |
| 1782 | - if ( ! in_array( $tag, $single_tags ) ) |
|
| 1783 | - $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; |
|
| 1782 | + if ( ! in_array($tag, $single_tags)) |
|
| 1783 | + $regex[2] = trim(substr($regex[2], 0, -1))."></$tag"; |
|
| 1784 | 1784 | } |
| 1785 | 1785 | // ElseIf it's a known single-entity tag but it doesn't close itself, do so |
| 1786 | - elseif ( in_array($tag, $single_tags) ) { |
|
| 1786 | + elseif (in_array($tag, $single_tags)) { |
|
| 1787 | 1787 | $regex[2] .= '/'; |
| 1788 | 1788 | } |
| 1789 | 1789 | // Else it's not a single-entity tag |
| 1790 | 1790 | else { |
| 1791 | 1791 | // If the top of the stack is the same as the tag we want to push, close previous tag |
| 1792 | - if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { |
|
| 1793 | - $tagqueue = '</' . array_pop( $tagstack ) . '>'; |
|
| 1792 | + if ($stacksize > 0 && ! in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag) { |
|
| 1793 | + $tagqueue = '</'.array_pop($tagstack).'>'; |
|
| 1794 | 1794 | $stacksize--; |
| 1795 | 1795 | } |
| 1796 | - $stacksize = array_push( $tagstack, $tag ); |
|
| 1796 | + $stacksize = array_push($tagstack, $tag); |
|
| 1797 | 1797 | } |
| 1798 | 1798 | |
| 1799 | 1799 | // Attributes |
| 1800 | 1800 | $attributes = $regex[2]; |
| 1801 | - if ( ! empty( $attributes ) && $attributes[0] != '>' ) |
|
| 1802 | - $attributes = ' ' . $attributes; |
|
| 1801 | + if ( ! empty($attributes) && $attributes[0] != '>') |
|
| 1802 | + $attributes = ' '.$attributes; |
|
| 1803 | 1803 | |
| 1804 | - $tag = '<' . $tag . $attributes . '>'; |
|
| 1804 | + $tag = '<'.$tag.$attributes.'>'; |
|
| 1805 | 1805 | //If already queuing a close tag, then put this tag on, too |
| 1806 | - if ( !empty($tagqueue) ) { |
|
| 1806 | + if ( ! empty($tagqueue)) { |
|
| 1807 | 1807 | $tagqueue .= $tag; |
| 1808 | 1808 | $tag = ''; |
| 1809 | 1809 | } |
| 1810 | 1810 | } |
| 1811 | - $newtext .= substr($text, 0, $i) . $tag; |
|
| 1811 | + $newtext .= substr($text, 0, $i).$tag; |
|
| 1812 | 1812 | $text = substr($text, $i + $l); |
| 1813 | 1813 | } |
| 1814 | 1814 | |
@@ -1819,12 +1819,12 @@ discard block |
||
| 1819 | 1819 | $newtext .= $text; |
| 1820 | 1820 | |
| 1821 | 1821 | // Empty Stack |
| 1822 | - while( $x = array_pop($tagstack) ) |
|
| 1823 | - $newtext .= '</' . $x . '>'; // Add remaining tags to close |
|
| 1822 | + while ($x = array_pop($tagstack)) |
|
| 1823 | + $newtext .= '</'.$x.'>'; // Add remaining tags to close |
|
| 1824 | 1824 | |
| 1825 | 1825 | // WP fix for the bug with HTML comments |
| 1826 | - $newtext = str_replace("< !--","<!--",$newtext); |
|
| 1827 | - $newtext = str_replace("< !--","< !--",$newtext); |
|
| 1826 | + $newtext = str_replace("< !--", "<!--", $newtext); |
|
| 1827 | + $newtext = str_replace("< !--", "< !--", $newtext); |
|
| 1828 | 1828 | |
| 1829 | 1829 | return $newtext; |
| 1830 | 1830 | } |
@@ -1842,7 +1842,7 @@ discard block |
||
| 1842 | 1842 | * @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed). |
| 1843 | 1843 | * @return string The text after the filter (and possibly htmlspecialchars()) has been run. |
| 1844 | 1844 | */ |
| 1845 | -function format_to_edit( $content, $richedit = false ) { |
|
| 1845 | +function format_to_edit($content, $richedit = false) { |
|
| 1846 | 1846 | /** |
| 1847 | 1847 | * Filter the text to be formatted for editing. |
| 1848 | 1848 | * |
@@ -1850,9 +1850,9 @@ discard block |
||
| 1850 | 1850 | * |
| 1851 | 1851 | * @param string $content The text, prior to formatting for editing. |
| 1852 | 1852 | */ |
| 1853 | - $content = apply_filters( 'format_to_edit', $content ); |
|
| 1854 | - if ( ! $richedit ) |
|
| 1855 | - $content = esc_textarea( $content ); |
|
| 1853 | + $content = apply_filters('format_to_edit', $content); |
|
| 1854 | + if ( ! $richedit) |
|
| 1855 | + $content = esc_textarea($content); |
|
| 1856 | 1856 | return $content; |
| 1857 | 1857 | } |
| 1858 | 1858 | |
@@ -1873,8 +1873,8 @@ discard block |
||
| 1873 | 1873 | * @param int $threshold Digit places number needs to be to not have zeros added. |
| 1874 | 1874 | * @return string Adds leading zeros to number if needed. |
| 1875 | 1875 | */ |
| 1876 | -function zeroise( $number, $threshold ) { |
|
| 1877 | - return sprintf( '%0' . $threshold . 's', $number ); |
|
| 1876 | +function zeroise($number, $threshold) { |
|
| 1877 | + return sprintf('%0'.$threshold.'s', $number); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | /** |
@@ -1885,10 +1885,10 @@ discard block |
||
| 1885 | 1885 | * @param string $string Value to which backslashes will be added. |
| 1886 | 1886 | * @return string String with backslashes inserted. |
| 1887 | 1887 | */ |
| 1888 | -function backslashit( $string ) { |
|
| 1889 | - if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) |
|
| 1890 | - $string = '\\\\' . $string; |
|
| 1891 | - return addcslashes( $string, 'A..Za..z' ); |
|
| 1888 | +function backslashit($string) { |
|
| 1889 | + if (isset($string[0]) && $string[0] >= '0' && $string[0] <= '9') |
|
| 1890 | + $string = '\\\\'.$string; |
|
| 1891 | + return addcslashes($string, 'A..Za..z'); |
|
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 1894 | 1894 | /** |
@@ -1905,8 +1905,8 @@ discard block |
||
| 1905 | 1905 | * @param string $string What to add the trailing slash to. |
| 1906 | 1906 | * @return string String with trailing slash added. |
| 1907 | 1907 | */ |
| 1908 | -function trailingslashit( $string ) { |
|
| 1909 | - return untrailingslashit( $string ) . '/'; |
|
| 1908 | +function trailingslashit($string) { |
|
| 1909 | + return untrailingslashit($string).'/'; |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | /** |
@@ -1920,8 +1920,8 @@ discard block |
||
| 1920 | 1920 | * @param string $string What to remove the trailing slashes from. |
| 1921 | 1921 | * @return string String without the trailing slashes. |
| 1922 | 1922 | */ |
| 1923 | -function untrailingslashit( $string ) { |
|
| 1924 | - return rtrim( $string, '/\\' ); |
|
| 1923 | +function untrailingslashit($string) { |
|
| 1924 | + return rtrim($string, '/\\'); |
|
| 1925 | 1925 | } |
| 1926 | 1926 | |
| 1927 | 1927 | /** |
@@ -1936,7 +1936,7 @@ discard block |
||
| 1936 | 1936 | * @return string Returns a string escaped with slashes. |
| 1937 | 1937 | */ |
| 1938 | 1938 | function addslashes_gpc($gpc) { |
| 1939 | - if ( get_magic_quotes_gpc() ) |
|
| 1939 | + if (get_magic_quotes_gpc()) |
|
| 1940 | 1940 | $gpc = stripslashes($gpc); |
| 1941 | 1941 | |
| 1942 | 1942 | return wp_slash($gpc); |
@@ -1953,15 +1953,15 @@ discard block |
||
| 1953 | 1953 | * @param mixed $value The value to be stripped. |
| 1954 | 1954 | * @return mixed Stripped value. |
| 1955 | 1955 | */ |
| 1956 | -function stripslashes_deep( $value ) { |
|
| 1957 | - if ( is_array($value) ) { |
|
| 1956 | +function stripslashes_deep($value) { |
|
| 1957 | + if (is_array($value)) { |
|
| 1958 | 1958 | $value = array_map('stripslashes_deep', $value); |
| 1959 | - } elseif ( is_object($value) ) { |
|
| 1960 | - $vars = get_object_vars( $value ); |
|
| 1959 | + } elseif (is_object($value)) { |
|
| 1960 | + $vars = get_object_vars($value); |
|
| 1961 | 1961 | foreach ($vars as $key=>$data) { |
| 1962 | - $value->{$key} = stripslashes_deep( $data ); |
|
| 1962 | + $value->{$key} = stripslashes_deep($data); |
|
| 1963 | 1963 | } |
| 1964 | - } elseif ( is_string( $value ) ) { |
|
| 1964 | + } elseif (is_string($value)) { |
|
| 1965 | 1965 | $value = stripslashes($value); |
| 1966 | 1966 | } |
| 1967 | 1967 | |
@@ -1977,8 +1977,8 @@ discard block |
||
| 1977 | 1977 | * @param array|string $value The array or string to be encoded. |
| 1978 | 1978 | * @return array|string $value The encoded array (or string from the callback). |
| 1979 | 1979 | */ |
| 1980 | -function urlencode_deep( $value ) { |
|
| 1981 | - return is_array( $value ) ? array_map( 'urlencode_deep', $value ) : urlencode( $value ); |
|
| 1980 | +function urlencode_deep($value) { |
|
| 1981 | + return is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | /** |
@@ -1989,8 +1989,8 @@ discard block |
||
| 1989 | 1989 | * @param array|string $value The array or string to be encoded. |
| 1990 | 1990 | * @return array|string $value The encoded array (or string from the callback). |
| 1991 | 1991 | */ |
| 1992 | -function rawurlencode_deep( $value ) { |
|
| 1993 | - return is_array( $value ) ? array_map( 'rawurlencode_deep', $value ) : rawurlencode( $value ); |
|
| 1992 | +function rawurlencode_deep($value) { |
|
| 1993 | + return is_array($value) ? array_map('rawurlencode_deep', $value) : rawurlencode($value); |
|
| 1994 | 1994 | } |
| 1995 | 1995 | |
| 1996 | 1996 | /** |
@@ -2002,20 +2002,20 @@ discard block |
||
| 2002 | 2002 | * @param int $hex_encoding Optional. Set to 1 to enable hex encoding. |
| 2003 | 2003 | * @return string Converted email address. |
| 2004 | 2004 | */ |
| 2005 | -function antispambot( $email_address, $hex_encoding = 0 ) { |
|
| 2005 | +function antispambot($email_address, $hex_encoding = 0) { |
|
| 2006 | 2006 | $email_no_spam_address = ''; |
| 2007 | - for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) { |
|
| 2008 | - $j = rand( 0, 1 + $hex_encoding ); |
|
| 2009 | - if ( $j == 0 ) { |
|
| 2010 | - $email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';'; |
|
| 2011 | - } elseif ( $j == 1 ) { |
|
| 2007 | + for ($i = 0, $len = strlen($email_address); $i < $len; $i++) { |
|
| 2008 | + $j = rand(0, 1 + $hex_encoding); |
|
| 2009 | + if ($j == 0) { |
|
| 2010 | + $email_no_spam_address .= '&#'.ord($email_address[$i]).';'; |
|
| 2011 | + } elseif ($j == 1) { |
|
| 2012 | 2012 | $email_no_spam_address .= $email_address[$i]; |
| 2013 | - } elseif ( $j == 2 ) { |
|
| 2014 | - $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 ); |
|
| 2013 | + } elseif ($j == 2) { |
|
| 2014 | + $email_no_spam_address .= '%'.zeroise(dechex(ord($email_address[$i])), 2); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | - return str_replace( '@', '@', $email_no_spam_address ); |
|
| 2018 | + return str_replace('@', '@', $email_no_spam_address); |
|
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | /** |
@@ -2030,10 +2030,10 @@ discard block |
||
| 2030 | 2030 | * @param array $matches Single Regex Match. |
| 2031 | 2031 | * @return string HTML A element with URI address. |
| 2032 | 2032 | */ |
| 2033 | -function _make_url_clickable_cb( $matches ) { |
|
| 2033 | +function _make_url_clickable_cb($matches) { |
|
| 2034 | 2034 | $url = $matches[2]; |
| 2035 | 2035 | |
| 2036 | - if ( ')' == $matches[3] && strpos( $url, '(' ) ) { |
|
| 2036 | + if (')' == $matches[3] && strpos($url, '(')) { |
|
| 2037 | 2037 | // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. |
| 2038 | 2038 | // Then we can let the parenthesis balancer do its thing below. |
| 2039 | 2039 | $url .= $matches[3]; |
@@ -2043,16 +2043,16 @@ discard block |
||
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | 2045 | // Include parentheses in the URL only if paired |
| 2046 | - while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { |
|
| 2047 | - $suffix = strrchr( $url, ')' ) . $suffix; |
|
| 2048 | - $url = substr( $url, 0, strrpos( $url, ')' ) ); |
|
| 2046 | + while (substr_count($url, '(') < substr_count($url, ')')) { |
|
| 2047 | + $suffix = strrchr($url, ')').$suffix; |
|
| 2048 | + $url = substr($url, 0, strrpos($url, ')')); |
|
| 2049 | 2049 | } |
| 2050 | 2050 | |
| 2051 | 2051 | $url = esc_url($url); |
| 2052 | - if ( empty($url) ) |
|
| 2052 | + if (empty($url)) |
|
| 2053 | 2053 | return $matches[0]; |
| 2054 | 2054 | |
| 2055 | - return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; |
|
| 2055 | + return $matches[1]."<a href=\"$url\" rel=\"nofollow\">$url</a>".$suffix; |
|
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | /** |
@@ -2067,20 +2067,20 @@ discard block |
||
| 2067 | 2067 | * @param array $matches Single Regex Match. |
| 2068 | 2068 | * @return string HTML A element with URL address. |
| 2069 | 2069 | */ |
| 2070 | -function _make_web_ftp_clickable_cb( $matches ) { |
|
| 2070 | +function _make_web_ftp_clickable_cb($matches) { |
|
| 2071 | 2071 | $ret = ''; |
| 2072 | 2072 | $dest = $matches[2]; |
| 2073 | - $dest = 'http://' . $dest; |
|
| 2073 | + $dest = 'http://'.$dest; |
|
| 2074 | 2074 | $dest = esc_url($dest); |
| 2075 | - if ( empty($dest) ) |
|
| 2075 | + if (empty($dest)) |
|
| 2076 | 2076 | return $matches[0]; |
| 2077 | 2077 | |
| 2078 | 2078 | // removed trailing [.,;:)] from URL |
| 2079 | - if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) { |
|
| 2079 | + if (in_array(substr($dest, -1), array('.', ',', ';', ':', ')')) === true) { |
|
| 2080 | 2080 | $ret = substr($dest, -1); |
| 2081 | - $dest = substr($dest, 0, strlen($dest)-1); |
|
| 2081 | + $dest = substr($dest, 0, strlen($dest) - 1); |
|
| 2082 | 2082 | } |
| 2083 | - return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; |
|
| 2083 | + return $matches[1]."<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; |
|
| 2084 | 2084 | } |
| 2085 | 2085 | |
| 2086 | 2086 | /** |
@@ -2095,9 +2095,9 @@ discard block |
||
| 2095 | 2095 | * @param array $matches Single Regex Match. |
| 2096 | 2096 | * @return string HTML A element with email address. |
| 2097 | 2097 | */ |
| 2098 | -function _make_email_clickable_cb( $matches ) { |
|
| 2099 | - $email = $matches[2] . '@' . $matches[3]; |
|
| 2100 | - return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; |
|
| 2098 | +function _make_email_clickable_cb($matches) { |
|
| 2099 | + $email = $matches[2].'@'.$matches[3]; |
|
| 2100 | + return $matches[1]."<a href=\"mailto:$email\">$email</a>"; |
|
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | /** |
@@ -2111,30 +2111,30 @@ discard block |
||
| 2111 | 2111 | * @param string $text Content to convert URIs. |
| 2112 | 2112 | * @return string Content with converted URIs. |
| 2113 | 2113 | */ |
| 2114 | -function make_clickable( $text ) { |
|
| 2114 | +function make_clickable($text) { |
|
| 2115 | 2115 | $r = ''; |
| 2116 | - $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags |
|
| 2116 | + $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags |
|
| 2117 | 2117 | $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> |
| 2118 | - foreach ( $textarr as $piece ) { |
|
| 2118 | + foreach ($textarr as $piece) { |
|
| 2119 | 2119 | |
| 2120 | - if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) |
|
| 2120 | + if (preg_match('|^<code[\s>]|i', $piece) || preg_match('|^<pre[\s>]|i', $piece)) |
|
| 2121 | 2121 | $nested_code_pre++; |
| 2122 | - elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) |
|
| 2122 | + elseif (('</code>' === strtolower($piece) || '</pre>' === strtolower($piece)) && $nested_code_pre) |
|
| 2123 | 2123 | $nested_code_pre--; |
| 2124 | 2124 | |
| 2125 | - if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) { |
|
| 2125 | + if ($nested_code_pre || empty($piece) || ($piece[0] === '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece))) { |
|
| 2126 | 2126 | $r .= $piece; |
| 2127 | 2127 | continue; |
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | 2130 | // Long strings might contain expensive edge cases ... |
| 2131 | - if ( 10000 < strlen( $piece ) ) { |
|
| 2131 | + if (10000 < strlen($piece)) { |
|
| 2132 | 2132 | // ... break it up |
| 2133 | - foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses |
|
| 2134 | - if ( 2101 < strlen( $chunk ) ) { |
|
| 2133 | + foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses |
|
| 2134 | + if (2101 < strlen($chunk)) { |
|
| 2135 | 2135 | $r .= $chunk; // Too big, no whitespace: bail. |
| 2136 | 2136 | } else { |
| 2137 | - $r .= make_clickable( $chunk ); |
|
| 2137 | + $r .= make_clickable($chunk); |
|
| 2138 | 2138 | } |
| 2139 | 2139 | } |
| 2140 | 2140 | } else { |
@@ -2155,18 +2155,18 @@ discard block |
||
| 2155 | 2155 | ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. |
| 2156 | 2156 | // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. |
| 2157 | 2157 | |
| 2158 | - $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); |
|
| 2158 | + $ret = preg_replace_callback($url_clickable, '_make_url_clickable_cb', $ret); |
|
| 2159 | 2159 | |
| 2160 | - $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret ); |
|
| 2161 | - $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); |
|
| 2160 | + $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); |
|
| 2161 | + $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); |
|
| 2162 | 2162 | |
| 2163 | - $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. |
|
| 2163 | + $ret = substr($ret, 1, -1); // Remove our whitespace padding. |
|
| 2164 | 2164 | $r .= $ret; |
| 2165 | 2165 | } |
| 2166 | 2166 | } |
| 2167 | 2167 | |
| 2168 | 2168 | // Cleanup of accidental links within links |
| 2169 | - return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); |
|
| 2169 | + return preg_replace('#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r); |
|
| 2170 | 2170 | } |
| 2171 | 2171 | |
| 2172 | 2172 | /** |
@@ -2198,27 +2198,27 @@ discard block |
||
| 2198 | 2198 | * @param int $goal The desired chunk length. |
| 2199 | 2199 | * @return array Numeric array of chunks. |
| 2200 | 2200 | */ |
| 2201 | -function _split_str_by_whitespace( $string, $goal ) { |
|
| 2201 | +function _split_str_by_whitespace($string, $goal) { |
|
| 2202 | 2202 | $chunks = array(); |
| 2203 | 2203 | |
| 2204 | - $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); |
|
| 2204 | + $string_nullspace = strtr($string, "\r\n\t\v\f ", "\000\000\000\000\000\000"); |
|
| 2205 | 2205 | |
| 2206 | - while ( $goal < strlen( $string_nullspace ) ) { |
|
| 2207 | - $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); |
|
| 2206 | + while ($goal < strlen($string_nullspace)) { |
|
| 2207 | + $pos = strrpos(substr($string_nullspace, 0, $goal + 1), "\000"); |
|
| 2208 | 2208 | |
| 2209 | - if ( false === $pos ) { |
|
| 2210 | - $pos = strpos( $string_nullspace, "\000", $goal + 1 ); |
|
| 2211 | - if ( false === $pos ) { |
|
| 2209 | + if (false === $pos) { |
|
| 2210 | + $pos = strpos($string_nullspace, "\000", $goal + 1); |
|
| 2211 | + if (false === $pos) { |
|
| 2212 | 2212 | break; |
| 2213 | 2213 | } |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | - $chunks[] = substr( $string, 0, $pos + 1 ); |
|
| 2217 | - $string = substr( $string, $pos + 1 ); |
|
| 2218 | - $string_nullspace = substr( $string_nullspace, $pos + 1 ); |
|
| 2216 | + $chunks[] = substr($string, 0, $pos + 1); |
|
| 2217 | + $string = substr($string, $pos + 1); |
|
| 2218 | + $string_nullspace = substr($string_nullspace, $pos + 1); |
|
| 2219 | 2219 | } |
| 2220 | 2220 | |
| 2221 | - if ( $string ) { |
|
| 2221 | + if ($string) { |
|
| 2222 | 2222 | $chunks[] = $string; |
| 2223 | 2223 | } |
| 2224 | 2224 | |
@@ -2233,11 +2233,11 @@ discard block |
||
| 2233 | 2233 | * @param string $text Content that may contain HTML A elements. |
| 2234 | 2234 | * @return string Converted content. |
| 2235 | 2235 | */ |
| 2236 | -function wp_rel_nofollow( $text ) { |
|
| 2236 | +function wp_rel_nofollow($text) { |
|
| 2237 | 2237 | // This is a pre save filter, so text is already escaped. |
| 2238 | 2238 | $text = stripslashes($text); |
| 2239 | 2239 | $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); |
| 2240 | - return wp_slash( $text ); |
|
| 2240 | + return wp_slash($text); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | * @param array $matches Single Match |
| 2252 | 2252 | * @return string HTML A Element with rel nofollow. |
| 2253 | 2253 | */ |
| 2254 | -function wp_rel_nofollow_callback( $matches ) { |
|
| 2254 | +function wp_rel_nofollow_callback($matches) { |
|
| 2255 | 2255 | $text = $matches[1]; |
| 2256 | 2256 | $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text); |
| 2257 | 2257 | return "<a $text rel=\"nofollow\">"; |
@@ -2271,21 +2271,21 @@ discard block |
||
| 2271 | 2271 | * @param array $matches Single match. Smiley code to convert to image. |
| 2272 | 2272 | * @return string Image string for smiley. |
| 2273 | 2273 | */ |
| 2274 | -function translate_smiley( $matches ) { |
|
| 2274 | +function translate_smiley($matches) { |
|
| 2275 | 2275 | global $wpsmiliestrans; |
| 2276 | 2276 | |
| 2277 | - if ( count( $matches ) == 0 ) |
|
| 2277 | + if (count($matches) == 0) |
|
| 2278 | 2278 | return ''; |
| 2279 | 2279 | |
| 2280 | - $smiley = trim( reset( $matches ) ); |
|
| 2281 | - $img = $wpsmiliestrans[ $smiley ]; |
|
| 2280 | + $smiley = trim(reset($matches)); |
|
| 2281 | + $img = $wpsmiliestrans[$smiley]; |
|
| 2282 | 2282 | |
| 2283 | 2283 | $matches = array(); |
| 2284 | - $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; |
|
| 2285 | - $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); |
|
| 2284 | + $ext = preg_match('/\.([^.]+)$/', $img, $matches) ? strtolower($matches[1]) : false; |
|
| 2285 | + $image_exts = array('jpg', 'jpeg', 'jpe', 'gif', 'png'); |
|
| 2286 | 2286 | |
| 2287 | 2287 | // Don't convert smilies that aren't images - they're probably emoji. |
| 2288 | - if ( ! in_array( $ext, $image_exts ) ) { |
|
| 2288 | + if ( ! in_array($ext, $image_exts)) { |
|
| 2289 | 2289 | return $img; |
| 2290 | 2290 | } |
| 2291 | 2291 | |
@@ -2298,9 +2298,9 @@ discard block |
||
| 2298 | 2298 | * @param string $img Filename for the smiley image. |
| 2299 | 2299 | * @param string $site_url Site URL, as returned by site_url(). |
| 2300 | 2300 | */ |
| 2301 | - $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); |
|
| 2301 | + $src_url = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url()); |
|
| 2302 | 2302 | |
| 2303 | - return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) ); |
|
| 2303 | + return sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url($src_url), esc_attr($smiley)); |
|
| 2304 | 2304 | } |
| 2305 | 2305 | |
| 2306 | 2306 | /** |
@@ -2316,33 +2316,33 @@ discard block |
||
| 2316 | 2316 | * @param string $text Content to convert smilies from text. |
| 2317 | 2317 | * @return string Converted content with text smilies replaced with images. |
| 2318 | 2318 | */ |
| 2319 | -function convert_smilies( $text ) { |
|
| 2319 | +function convert_smilies($text) { |
|
| 2320 | 2320 | global $wp_smiliessearch; |
| 2321 | 2321 | $output = ''; |
| 2322 | - if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) { |
|
| 2322 | + if (get_option('use_smilies') && ! empty($wp_smiliessearch)) { |
|
| 2323 | 2323 | // HTML loop taken from texturize function, could possible be consolidated |
| 2324 | - $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between |
|
| 2325 | - $stop = count( $textarr );// loop stuff |
|
| 2324 | + $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between |
|
| 2325 | + $stop = count($textarr); // loop stuff |
|
| 2326 | 2326 | |
| 2327 | 2327 | // Ignore proessing of specific tags |
| 2328 | 2328 | $tags_to_ignore = 'code|pre|style|script|textarea'; |
| 2329 | 2329 | $ignore_block_element = ''; |
| 2330 | 2330 | |
| 2331 | - for ( $i = 0; $i < $stop; $i++ ) { |
|
| 2331 | + for ($i = 0; $i < $stop; $i++) { |
|
| 2332 | 2332 | $content = $textarr[$i]; |
| 2333 | 2333 | |
| 2334 | 2334 | // If we're in an ignore block, wait until we find its closing tag |
| 2335 | - if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { |
|
| 2335 | + if ('' == $ignore_block_element && preg_match('/^<('.$tags_to_ignore.')>/', $content, $matches)) { |
|
| 2336 | 2336 | $ignore_block_element = $matches[1]; |
| 2337 | 2337 | } |
| 2338 | 2338 | |
| 2339 | 2339 | // If it's not a tag and not in ignore block |
| 2340 | - if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { |
|
| 2341 | - $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); |
|
| 2340 | + if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) { |
|
| 2341 | + $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content); |
|
| 2342 | 2342 | } |
| 2343 | 2343 | |
| 2344 | 2344 | // did we exit ignore block |
| 2345 | - if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { |
|
| 2345 | + if ('' != $ignore_block_element && '</'.$ignore_block_element.'>' == $content) { |
|
| 2346 | 2346 | $ignore_block_element = ''; |
| 2347 | 2347 | } |
| 2348 | 2348 | |
@@ -2366,12 +2366,12 @@ discard block |
||
| 2366 | 2366 | * @param bool $deprecated Deprecated. |
| 2367 | 2367 | * @return string|bool Either false or the valid email address. |
| 2368 | 2368 | */ |
| 2369 | -function is_email( $email, $deprecated = false ) { |
|
| 2370 | - if ( ! empty( $deprecated ) ) |
|
| 2371 | - _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 2369 | +function is_email($email, $deprecated = false) { |
|
| 2370 | + if ( ! empty($deprecated)) |
|
| 2371 | + _deprecated_argument(__FUNCTION__, '3.0'); |
|
| 2372 | 2372 | |
| 2373 | 2373 | // Test for the minimum length the email can be |
| 2374 | - if ( strlen( $email ) < 3 ) { |
|
| 2374 | + if (strlen($email) < 3) { |
|
| 2375 | 2375 | /** |
| 2376 | 2376 | * Filter whether an email address is valid. |
| 2377 | 2377 | * |
@@ -2386,65 +2386,65 @@ discard block |
||
| 2386 | 2386 | * @param string $message An explanatory message to the user. |
| 2387 | 2387 | * @param string $context Context under which the email was tested. |
| 2388 | 2388 | */ |
| 2389 | - return apply_filters( 'is_email', false, $email, 'email_too_short' ); |
|
| 2389 | + return apply_filters('is_email', false, $email, 'email_too_short'); |
|
| 2390 | 2390 | } |
| 2391 | 2391 | |
| 2392 | 2392 | // Test for an @ character after the first position |
| 2393 | - if ( strpos( $email, '@', 1 ) === false ) { |
|
| 2393 | + if (strpos($email, '@', 1) === false) { |
|
| 2394 | 2394 | /** This filter is documented in wp-includes/formatting.php */ |
| 2395 | - return apply_filters( 'is_email', false, $email, 'email_no_at' ); |
|
| 2395 | + return apply_filters('is_email', false, $email, 'email_no_at'); |
|
| 2396 | 2396 | } |
| 2397 | 2397 | |
| 2398 | 2398 | // Split out the local and domain parts |
| 2399 | - list( $local, $domain ) = explode( '@', $email, 2 ); |
|
| 2399 | + list($local, $domain) = explode('@', $email, 2); |
|
| 2400 | 2400 | |
| 2401 | 2401 | // LOCAL PART |
| 2402 | 2402 | // Test for invalid characters |
| 2403 | - if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { |
|
| 2403 | + if ( ! preg_match('/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local)) { |
|
| 2404 | 2404 | /** This filter is documented in wp-includes/formatting.php */ |
| 2405 | - return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); |
|
| 2405 | + return apply_filters('is_email', false, $email, 'local_invalid_chars'); |
|
| 2406 | 2406 | } |
| 2407 | 2407 | |
| 2408 | 2408 | // DOMAIN PART |
| 2409 | 2409 | // Test for sequences of periods |
| 2410 | - if ( preg_match( '/\.{2,}/', $domain ) ) { |
|
| 2410 | + if (preg_match('/\.{2,}/', $domain)) { |
|
| 2411 | 2411 | /** This filter is documented in wp-includes/formatting.php */ |
| 2412 | - return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); |
|
| 2412 | + return apply_filters('is_email', false, $email, 'domain_period_sequence'); |
|
| 2413 | 2413 | } |
| 2414 | 2414 | |
| 2415 | 2415 | // Test for leading and trailing periods and whitespace |
| 2416 | - if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { |
|
| 2416 | + if (trim($domain, " \t\n\r\0\x0B.") !== $domain) { |
|
| 2417 | 2417 | /** This filter is documented in wp-includes/formatting.php */ |
| 2418 | - return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); |
|
| 2418 | + return apply_filters('is_email', false, $email, 'domain_period_limits'); |
|
| 2419 | 2419 | } |
| 2420 | 2420 | |
| 2421 | 2421 | // Split the domain into subs |
| 2422 | - $subs = explode( '.', $domain ); |
|
| 2422 | + $subs = explode('.', $domain); |
|
| 2423 | 2423 | |
| 2424 | 2424 | // Assume the domain will have at least two subs |
| 2425 | - if ( 2 > count( $subs ) ) { |
|
| 2425 | + if (2 > count($subs)) { |
|
| 2426 | 2426 | /** This filter is documented in wp-includes/formatting.php */ |
| 2427 | - return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); |
|
| 2427 | + return apply_filters('is_email', false, $email, 'domain_no_periods'); |
|
| 2428 | 2428 | } |
| 2429 | 2429 | |
| 2430 | 2430 | // Loop through each sub |
| 2431 | - foreach ( $subs as $sub ) { |
|
| 2431 | + foreach ($subs as $sub) { |
|
| 2432 | 2432 | // Test for leading and trailing hyphens and whitespace |
| 2433 | - if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { |
|
| 2433 | + if (trim($sub, " \t\n\r\0\x0B-") !== $sub) { |
|
| 2434 | 2434 | /** This filter is documented in wp-includes/formatting.php */ |
| 2435 | - return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); |
|
| 2435 | + return apply_filters('is_email', false, $email, 'sub_hyphen_limits'); |
|
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | 2438 | // Test for invalid characters |
| 2439 | - if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { |
|
| 2439 | + if ( ! preg_match('/^[a-z0-9-]+$/i', $sub)) { |
|
| 2440 | 2440 | /** This filter is documented in wp-includes/formatting.php */ |
| 2441 | - return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); |
|
| 2441 | + return apply_filters('is_email', false, $email, 'sub_invalid_chars'); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | } |
| 2444 | 2444 | |
| 2445 | 2445 | // Congratulations your email made it! |
| 2446 | 2446 | /** This filter is documented in wp-includes/formatting.php */ |
| 2447 | - return apply_filters( 'is_email', $email, $email, null ); |
|
| 2447 | + return apply_filters('is_email', $email, $email, null); |
|
| 2448 | 2448 | } |
| 2449 | 2449 | |
| 2450 | 2450 | /** |
@@ -2455,13 +2455,13 @@ discard block |
||
| 2455 | 2455 | * @param string $string Subject line |
| 2456 | 2456 | * @return string Converted string to ASCII |
| 2457 | 2457 | */ |
| 2458 | -function wp_iso_descrambler( $string ) { |
|
| 2458 | +function wp_iso_descrambler($string) { |
|
| 2459 | 2459 | /* this may only work with iso-8859-1, I'm afraid */ |
| 2460 | - if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) { |
|
| 2460 | + if ( ! preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) { |
|
| 2461 | 2461 | return $string; |
| 2462 | 2462 | } else { |
| 2463 | 2463 | $subject = str_replace('_', ' ', $matches[2]); |
| 2464 | - return preg_replace_callback( '#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject ); |
|
| 2464 | + return preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject); |
|
| 2465 | 2465 | } |
| 2466 | 2466 | } |
| 2467 | 2467 | |
@@ -2474,8 +2474,8 @@ discard block |
||
| 2474 | 2474 | * @param array $match The preg_replace_callback matches array |
| 2475 | 2475 | * @return string Converted chars |
| 2476 | 2476 | */ |
| 2477 | -function _wp_iso_convert( $match ) { |
|
| 2478 | - return chr( hexdec( strtolower( $match[1] ) ) ); |
|
| 2477 | +function _wp_iso_convert($match) { |
|
| 2478 | + return chr(hexdec(strtolower($match[1]))); |
|
| 2479 | 2479 | } |
| 2480 | 2480 | |
| 2481 | 2481 | /** |
@@ -2492,19 +2492,19 @@ discard block |
||
| 2492 | 2492 | * @param string $format The format string for the returned date (default is Y-m-d H:i:s) |
| 2493 | 2493 | * @return string GMT version of the date provided. |
| 2494 | 2494 | */ |
| 2495 | -function get_gmt_from_date( $string, $format = 'Y-m-d H:i:s' ) { |
|
| 2496 | - $tz = get_option( 'timezone_string' ); |
|
| 2497 | - if ( $tz ) { |
|
| 2498 | - $datetime = date_create( $string, new DateTimeZone( $tz ) ); |
|
| 2499 | - if ( ! $datetime ) |
|
| 2500 | - return gmdate( $format, 0 ); |
|
| 2501 | - $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); |
|
| 2502 | - $string_gmt = $datetime->format( $format ); |
|
| 2495 | +function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { |
|
| 2496 | + $tz = get_option('timezone_string'); |
|
| 2497 | + if ($tz) { |
|
| 2498 | + $datetime = date_create($string, new DateTimeZone($tz)); |
|
| 2499 | + if ( ! $datetime) |
|
| 2500 | + return gmdate($format, 0); |
|
| 2501 | + $datetime->setTimezone(new DateTimeZone('UTC')); |
|
| 2502 | + $string_gmt = $datetime->format($format); |
|
| 2503 | 2503 | } else { |
| 2504 | - if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) |
|
| 2505 | - return gmdate( $format, 0 ); |
|
| 2506 | - $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
|
| 2507 | - $string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
|
| 2504 | + if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches)) |
|
| 2505 | + return gmdate($format, 0); |
|
| 2506 | + $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 2507 | + $string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * HOUR_IN_SECONDS); |
|
| 2508 | 2508 | } |
| 2509 | 2509 | return $string_gmt; |
| 2510 | 2510 | } |
@@ -2523,19 +2523,19 @@ discard block |
||
| 2523 | 2523 | * @param string $format The format string for the returned date (default is Y-m-d H:i:s) |
| 2524 | 2524 | * @return string Formatted date relative to the timezone / GMT offset. |
| 2525 | 2525 | */ |
| 2526 | -function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) { |
|
| 2527 | - $tz = get_option( 'timezone_string' ); |
|
| 2528 | - if ( $tz ) { |
|
| 2529 | - $datetime = date_create( $string, new DateTimeZone( 'UTC' ) ); |
|
| 2530 | - if ( ! $datetime ) |
|
| 2531 | - return date( $format, 0 ); |
|
| 2532 | - $datetime->setTimezone( new DateTimeZone( $tz ) ); |
|
| 2533 | - $string_localtime = $datetime->format( $format ); |
|
| 2526 | +function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') { |
|
| 2527 | + $tz = get_option('timezone_string'); |
|
| 2528 | + if ($tz) { |
|
| 2529 | + $datetime = date_create($string, new DateTimeZone('UTC')); |
|
| 2530 | + if ( ! $datetime) |
|
| 2531 | + return date($format, 0); |
|
| 2532 | + $datetime->setTimezone(new DateTimeZone($tz)); |
|
| 2533 | + $string_localtime = $datetime->format($format); |
|
| 2534 | 2534 | } else { |
| 2535 | - if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) ) |
|
| 2536 | - return date( $format, 0 ); |
|
| 2537 | - $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
|
| 2538 | - $string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
|
| 2535 | + if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches)) |
|
| 2536 | + return date($format, 0); |
|
| 2537 | + $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 2538 | + $string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS); |
|
| 2539 | 2539 | } |
| 2540 | 2540 | return $string_localtime; |
| 2541 | 2541 | } |
@@ -2548,7 +2548,7 @@ discard block |
||
| 2548 | 2548 | * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. |
| 2549 | 2549 | * @return int|float The offset in seconds. |
| 2550 | 2550 | */ |
| 2551 | -function iso8601_timezone_to_offset( $timezone ) { |
|
| 2551 | +function iso8601_timezone_to_offset($timezone) { |
|
| 2552 | 2552 | // $timezone is either 'Z' or '[+|-]hhmm' |
| 2553 | 2553 | if ($timezone == 'Z') { |
| 2554 | 2554 | $offset = 0; |
@@ -2570,14 +2570,14 @@ discard block |
||
| 2570 | 2570 | * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. |
| 2571 | 2571 | * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. |
| 2572 | 2572 | */ |
| 2573 | -function iso8601_to_datetime( $date_string, $timezone = 'user' ) { |
|
| 2573 | +function iso8601_to_datetime($date_string, $timezone = 'user') { |
|
| 2574 | 2574 | $timezone = strtolower($timezone); |
| 2575 | 2575 | |
| 2576 | 2576 | if ($timezone == 'gmt') { |
| 2577 | 2577 | |
| 2578 | 2578 | preg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\+|\-][0-9]{2,4}){0,1}#', $date_string, $date_bits); |
| 2579 | 2579 | |
| 2580 | - if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset |
|
| 2580 | + if ( ! empty($date_bits[7])) { // we have a timezone, so let's compute an offset |
|
| 2581 | 2581 | $offset = iso8601_timezone_to_offset($date_bits[7]); |
| 2582 | 2582 | } else { // we don't have a timezone, so we assume user local timezone (not server's!) |
| 2583 | 2583 | $offset = HOUR_IN_SECONDS * get_option('gmt_offset'); |
@@ -2605,7 +2605,7 @@ discard block |
||
| 2605 | 2605 | * @param string $text Content to replace links to open in a new window. |
| 2606 | 2606 | * @return string Content that has filtered links. |
| 2607 | 2607 | */ |
| 2608 | -function popuplinks( $text ) { |
|
| 2608 | +function popuplinks($text) { |
|
| 2609 | 2609 | $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); |
| 2610 | 2610 | return $text; |
| 2611 | 2611 | } |
@@ -2618,9 +2618,9 @@ discard block |
||
| 2618 | 2618 | * @param string $email Email address to filter. |
| 2619 | 2619 | * @return string Filtered email address. |
| 2620 | 2620 | */ |
| 2621 | -function sanitize_email( $email ) { |
|
| 2621 | +function sanitize_email($email) { |
|
| 2622 | 2622 | // Test for the minimum length the email can be |
| 2623 | - if ( strlen( $email ) < 3 ) { |
|
| 2623 | + if (strlen($email) < 3) { |
|
| 2624 | 2624 | /** |
| 2625 | 2625 | * Filter a sanitized email address. |
| 2626 | 2626 | * |
@@ -2634,82 +2634,82 @@ discard block |
||
| 2634 | 2634 | * @param string $email The email address, as provided to sanitize_email(). |
| 2635 | 2635 | * @param string $message A message to pass to the user. |
| 2636 | 2636 | */ |
| 2637 | - return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); |
|
| 2637 | + return apply_filters('sanitize_email', '', $email, 'email_too_short'); |
|
| 2638 | 2638 | } |
| 2639 | 2639 | |
| 2640 | 2640 | // Test for an @ character after the first position |
| 2641 | - if ( strpos( $email, '@', 1 ) === false ) { |
|
| 2641 | + if (strpos($email, '@', 1) === false) { |
|
| 2642 | 2642 | /** This filter is documented in wp-includes/formatting.php */ |
| 2643 | - return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); |
|
| 2643 | + return apply_filters('sanitize_email', '', $email, 'email_no_at'); |
|
| 2644 | 2644 | } |
| 2645 | 2645 | |
| 2646 | 2646 | // Split out the local and domain parts |
| 2647 | - list( $local, $domain ) = explode( '@', $email, 2 ); |
|
| 2647 | + list($local, $domain) = explode('@', $email, 2); |
|
| 2648 | 2648 | |
| 2649 | 2649 | // LOCAL PART |
| 2650 | 2650 | // Test for invalid characters |
| 2651 | - $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); |
|
| 2652 | - if ( '' === $local ) { |
|
| 2651 | + $local = preg_replace('/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local); |
|
| 2652 | + if ('' === $local) { |
|
| 2653 | 2653 | /** This filter is documented in wp-includes/formatting.php */ |
| 2654 | - return apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' ); |
|
| 2654 | + return apply_filters('sanitize_email', '', $email, 'local_invalid_chars'); |
|
| 2655 | 2655 | } |
| 2656 | 2656 | |
| 2657 | 2657 | // DOMAIN PART |
| 2658 | 2658 | // Test for sequences of periods |
| 2659 | - $domain = preg_replace( '/\.{2,}/', '', $domain ); |
|
| 2660 | - if ( '' === $domain ) { |
|
| 2659 | + $domain = preg_replace('/\.{2,}/', '', $domain); |
|
| 2660 | + if ('' === $domain) { |
|
| 2661 | 2661 | /** This filter is documented in wp-includes/formatting.php */ |
| 2662 | - return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); |
|
| 2662 | + return apply_filters('sanitize_email', '', $email, 'domain_period_sequence'); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | // Test for leading and trailing periods and whitespace |
| 2666 | - $domain = trim( $domain, " \t\n\r\0\x0B." ); |
|
| 2667 | - if ( '' === $domain ) { |
|
| 2666 | + $domain = trim($domain, " \t\n\r\0\x0B."); |
|
| 2667 | + if ('' === $domain) { |
|
| 2668 | 2668 | /** This filter is documented in wp-includes/formatting.php */ |
| 2669 | - return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); |
|
| 2669 | + return apply_filters('sanitize_email', '', $email, 'domain_period_limits'); |
|
| 2670 | 2670 | } |
| 2671 | 2671 | |
| 2672 | 2672 | // Split the domain into subs |
| 2673 | - $subs = explode( '.', $domain ); |
|
| 2673 | + $subs = explode('.', $domain); |
|
| 2674 | 2674 | |
| 2675 | 2675 | // Assume the domain will have at least two subs |
| 2676 | - if ( 2 > count( $subs ) ) { |
|
| 2676 | + if (2 > count($subs)) { |
|
| 2677 | 2677 | /** This filter is documented in wp-includes/formatting.php */ |
| 2678 | - return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); |
|
| 2678 | + return apply_filters('sanitize_email', '', $email, 'domain_no_periods'); |
|
| 2679 | 2679 | } |
| 2680 | 2680 | |
| 2681 | 2681 | // Create an array that will contain valid subs |
| 2682 | 2682 | $new_subs = array(); |
| 2683 | 2683 | |
| 2684 | 2684 | // Loop through each sub |
| 2685 | - foreach ( $subs as $sub ) { |
|
| 2685 | + foreach ($subs as $sub) { |
|
| 2686 | 2686 | // Test for leading and trailing hyphens |
| 2687 | - $sub = trim( $sub, " \t\n\r\0\x0B-" ); |
|
| 2687 | + $sub = trim($sub, " \t\n\r\0\x0B-"); |
|
| 2688 | 2688 | |
| 2689 | 2689 | // Test for invalid characters |
| 2690 | - $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); |
|
| 2690 | + $sub = preg_replace('/[^a-z0-9-]+/i', '', $sub); |
|
| 2691 | 2691 | |
| 2692 | 2692 | // If there's anything left, add it to the valid subs |
| 2693 | - if ( '' !== $sub ) { |
|
| 2693 | + if ('' !== $sub) { |
|
| 2694 | 2694 | $new_subs[] = $sub; |
| 2695 | 2695 | } |
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | // If there aren't 2 or more valid subs |
| 2699 | - if ( 2 > count( $new_subs ) ) { |
|
| 2699 | + if (2 > count($new_subs)) { |
|
| 2700 | 2700 | /** This filter is documented in wp-includes/formatting.php */ |
| 2701 | - return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); |
|
| 2701 | + return apply_filters('sanitize_email', '', $email, 'domain_no_valid_subs'); |
|
| 2702 | 2702 | } |
| 2703 | 2703 | |
| 2704 | 2704 | // Join valid subs into the new domain |
| 2705 | - $domain = join( '.', $new_subs ); |
|
| 2705 | + $domain = join('.', $new_subs); |
|
| 2706 | 2706 | |
| 2707 | 2707 | // Put the email back together |
| 2708 | - $email = $local . '@' . $domain; |
|
| 2708 | + $email = $local.'@'.$domain; |
|
| 2709 | 2709 | |
| 2710 | 2710 | // Congratulations your email made it! |
| 2711 | 2711 | /** This filter is documented in wp-includes/formatting.php */ |
| 2712 | - return apply_filters( 'sanitize_email', $email, $email, null ); |
|
| 2712 | + return apply_filters('sanitize_email', $email, $email, null); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | /** |
@@ -2724,44 +2724,44 @@ discard block |
||
| 2724 | 2724 | * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. |
| 2725 | 2725 | * @return string Human readable time difference. |
| 2726 | 2726 | */ |
| 2727 | -function human_time_diff( $from, $to = '' ) { |
|
| 2728 | - if ( empty( $to ) ) { |
|
| 2727 | +function human_time_diff($from, $to = '') { |
|
| 2728 | + if (empty($to)) { |
|
| 2729 | 2729 | $to = time(); |
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | - $diff = (int) abs( $to - $from ); |
|
| 2732 | + $diff = (int) abs($to - $from); |
|
| 2733 | 2733 | |
| 2734 | - if ( $diff < HOUR_IN_SECONDS ) { |
|
| 2735 | - $mins = round( $diff / MINUTE_IN_SECONDS ); |
|
| 2736 | - if ( $mins <= 1 ) |
|
| 2734 | + if ($diff < HOUR_IN_SECONDS) { |
|
| 2735 | + $mins = round($diff / MINUTE_IN_SECONDS); |
|
| 2736 | + if ($mins <= 1) |
|
| 2737 | 2737 | $mins = 1; |
| 2738 | 2738 | /* translators: min=minute */ |
| 2739 | - $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); |
|
| 2740 | - } elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { |
|
| 2741 | - $hours = round( $diff / HOUR_IN_SECONDS ); |
|
| 2742 | - if ( $hours <= 1 ) |
|
| 2739 | + $since = sprintf(_n('%s min', '%s mins', $mins), $mins); |
|
| 2740 | + } elseif ($diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS) { |
|
| 2741 | + $hours = round($diff / HOUR_IN_SECONDS); |
|
| 2742 | + if ($hours <= 1) |
|
| 2743 | 2743 | $hours = 1; |
| 2744 | - $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); |
|
| 2745 | - } elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) { |
|
| 2746 | - $days = round( $diff / DAY_IN_SECONDS ); |
|
| 2747 | - if ( $days <= 1 ) |
|
| 2744 | + $since = sprintf(_n('%s hour', '%s hours', $hours), $hours); |
|
| 2745 | + } elseif ($diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS) { |
|
| 2746 | + $days = round($diff / DAY_IN_SECONDS); |
|
| 2747 | + if ($days <= 1) |
|
| 2748 | 2748 | $days = 1; |
| 2749 | - $since = sprintf( _n( '%s day', '%s days', $days ), $days ); |
|
| 2750 | - } elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) { |
|
| 2751 | - $weeks = round( $diff / WEEK_IN_SECONDS ); |
|
| 2752 | - if ( $weeks <= 1 ) |
|
| 2749 | + $since = sprintf(_n('%s day', '%s days', $days), $days); |
|
| 2750 | + } elseif ($diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS) { |
|
| 2751 | + $weeks = round($diff / WEEK_IN_SECONDS); |
|
| 2752 | + if ($weeks <= 1) |
|
| 2753 | 2753 | $weeks = 1; |
| 2754 | - $since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks ); |
|
| 2755 | - } elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) { |
|
| 2756 | - $months = round( $diff / ( 30 * DAY_IN_SECONDS ) ); |
|
| 2757 | - if ( $months <= 1 ) |
|
| 2754 | + $since = sprintf(_n('%s week', '%s weeks', $weeks), $weeks); |
|
| 2755 | + } elseif ($diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS) { |
|
| 2756 | + $months = round($diff / (30 * DAY_IN_SECONDS)); |
|
| 2757 | + if ($months <= 1) |
|
| 2758 | 2758 | $months = 1; |
| 2759 | - $since = sprintf( _n( '%s month', '%s months', $months ), $months ); |
|
| 2760 | - } elseif ( $diff >= YEAR_IN_SECONDS ) { |
|
| 2761 | - $years = round( $diff / YEAR_IN_SECONDS ); |
|
| 2762 | - if ( $years <= 1 ) |
|
| 2759 | + $since = sprintf(_n('%s month', '%s months', $months), $months); |
|
| 2760 | + } elseif ($diff >= YEAR_IN_SECONDS) { |
|
| 2761 | + $years = round($diff / YEAR_IN_SECONDS); |
|
| 2762 | + if ($years <= 1) |
|
| 2763 | 2763 | $years = 1; |
| 2764 | - $since = sprintf( _n( '%s year', '%s years', $years ), $years ); |
|
| 2764 | + $since = sprintf(_n('%s year', '%s years', $years), $years); |
|
| 2765 | 2765 | } |
| 2766 | 2766 | |
| 2767 | 2767 | /** |
@@ -2774,7 +2774,7 @@ discard block |
||
| 2774 | 2774 | * @param int $from Unix timestamp from which the difference begins. |
| 2775 | 2775 | * @param int $to Unix timestamp to end the time difference. |
| 2776 | 2776 | */ |
| 2777 | - return apply_filters( 'human_time_diff', $since, $diff, $from, $to ); |
|
| 2777 | + return apply_filters('human_time_diff', $since, $diff, $from, $to); |
|
| 2778 | 2778 | } |
| 2779 | 2779 | |
| 2780 | 2780 | /** |
@@ -2792,15 +2792,15 @@ discard block |
||
| 2792 | 2792 | * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated. |
| 2793 | 2793 | * @return string The excerpt. |
| 2794 | 2794 | */ |
| 2795 | -function wp_trim_excerpt( $text = '' ) { |
|
| 2795 | +function wp_trim_excerpt($text = '') { |
|
| 2796 | 2796 | $raw_excerpt = $text; |
| 2797 | - if ( '' == $text ) { |
|
| 2797 | + if ('' == $text) { |
|
| 2798 | 2798 | $text = get_the_content(''); |
| 2799 | 2799 | |
| 2800 | - $text = strip_shortcodes( $text ); |
|
| 2800 | + $text = strip_shortcodes($text); |
|
| 2801 | 2801 | |
| 2802 | 2802 | /** This filter is documented in wp-includes/post-template.php */ |
| 2803 | - $text = apply_filters( 'the_content', $text ); |
|
| 2803 | + $text = apply_filters('the_content', $text); |
|
| 2804 | 2804 | $text = str_replace(']]>', ']]>', $text); |
| 2805 | 2805 | |
| 2806 | 2806 | /** |
@@ -2810,7 +2810,7 @@ discard block |
||
| 2810 | 2810 | * |
| 2811 | 2811 | * @param int $number The number of words. Default 55. |
| 2812 | 2812 | */ |
| 2813 | - $excerpt_length = apply_filters( 'excerpt_length', 55 ); |
|
| 2813 | + $excerpt_length = apply_filters('excerpt_length', 55); |
|
| 2814 | 2814 | /** |
| 2815 | 2815 | * Filter the string in the "more" link displayed after a trimmed excerpt. |
| 2816 | 2816 | * |
@@ -2818,8 +2818,8 @@ discard block |
||
| 2818 | 2818 | * |
| 2819 | 2819 | * @param string $more_string The string shown within the more link. |
| 2820 | 2820 | */ |
| 2821 | - $excerpt_more = apply_filters( 'excerpt_more', ' ' . '[…]' ); |
|
| 2822 | - $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); |
|
| 2821 | + $excerpt_more = apply_filters('excerpt_more', ' '.'[…]'); |
|
| 2822 | + $text = wp_trim_words($text, $excerpt_length, $excerpt_more); |
|
| 2823 | 2823 | } |
| 2824 | 2824 | /** |
| 2825 | 2825 | * Filter the trimmed excerpt string. |
@@ -2829,7 +2829,7 @@ discard block |
||
| 2829 | 2829 | * @param string $text The trimmed text. |
| 2830 | 2830 | * @param string $raw_excerpt The text prior to trimming. |
| 2831 | 2831 | */ |
| 2832 | - return apply_filters( 'wp_trim_excerpt', $text, $raw_excerpt ); |
|
| 2832 | + return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); |
|
| 2833 | 2833 | } |
| 2834 | 2834 | |
| 2835 | 2835 | /** |
@@ -2846,35 +2846,35 @@ discard block |
||
| 2846 | 2846 | * @param string $more Optional. What to append if $text needs to be trimmed. Default '…'. |
| 2847 | 2847 | * @return string Trimmed text. |
| 2848 | 2848 | */ |
| 2849 | -function wp_trim_words( $text, $num_words = 55, $more = null ) { |
|
| 2850 | - if ( null === $more ) { |
|
| 2851 | - $more = __( '…' ); |
|
| 2849 | +function wp_trim_words($text, $num_words = 55, $more = null) { |
|
| 2850 | + if (null === $more) { |
|
| 2851 | + $more = __('…'); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | $original_text = $text; |
| 2855 | - $text = wp_strip_all_tags( $text ); |
|
| 2855 | + $text = wp_strip_all_tags($text); |
|
| 2856 | 2856 | |
| 2857 | 2857 | /* |
| 2858 | 2858 | * translators: If your word count is based on single characters (e.g. East Asian characters), |
| 2859 | 2859 | * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. |
| 2860 | 2860 | * Do not translate into your own language. |
| 2861 | 2861 | */ |
| 2862 | - if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
| 2863 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
| 2864 | - preg_match_all( '/./u', $text, $words_array ); |
|
| 2865 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
| 2862 | + if (strpos(_x('words', 'Word count type. Do not translate!'), 'characters') === 0 && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
| 2863 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
| 2864 | + preg_match_all('/./u', $text, $words_array); |
|
| 2865 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
| 2866 | 2866 | $sep = ''; |
| 2867 | 2867 | } else { |
| 2868 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
| 2868 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
| 2869 | 2869 | $sep = ' '; |
| 2870 | 2870 | } |
| 2871 | 2871 | |
| 2872 | - if ( count( $words_array ) > $num_words ) { |
|
| 2873 | - array_pop( $words_array ); |
|
| 2874 | - $text = implode( $sep, $words_array ); |
|
| 2875 | - $text = $text . $more; |
|
| 2872 | + if (count($words_array) > $num_words) { |
|
| 2873 | + array_pop($words_array); |
|
| 2874 | + $text = implode($sep, $words_array); |
|
| 2875 | + $text = $text.$more; |
|
| 2876 | 2876 | } else { |
| 2877 | - $text = implode( $sep, $words_array ); |
|
| 2877 | + $text = implode($sep, $words_array); |
|
| 2878 | 2878 | } |
| 2879 | 2879 | |
| 2880 | 2880 | /** |
@@ -2887,7 +2887,7 @@ discard block |
||
| 2887 | 2887 | * @param string $more An optional string to append to the end of the trimmed text, e.g. …. |
| 2888 | 2888 | * @param string $original_text The text before it was trimmed. |
| 2889 | 2889 | */ |
| 2890 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
| 2890 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
| 2891 | 2891 | } |
| 2892 | 2892 | |
| 2893 | 2893 | /** |
@@ -2898,7 +2898,7 @@ discard block |
||
| 2898 | 2898 | * @param string $text The text within which entities will be converted. |
| 2899 | 2899 | * @return string Text with converted entities. |
| 2900 | 2900 | */ |
| 2901 | -function ent2ncr( $text ) { |
|
| 2901 | +function ent2ncr($text) { |
|
| 2902 | 2902 | |
| 2903 | 2903 | /** |
| 2904 | 2904 | * Filter text before named entities are converted into numbered entities. |
@@ -2910,8 +2910,8 @@ discard block |
||
| 2910 | 2910 | * @param null $converted_text The text to be converted. Default null. |
| 2911 | 2911 | * @param string $text The text prior to entity conversion. |
| 2912 | 2912 | */ |
| 2913 | - $filtered = apply_filters( 'pre_ent2ncr', null, $text ); |
|
| 2914 | - if ( null !== $filtered ) |
|
| 2913 | + $filtered = apply_filters('pre_ent2ncr', null, $text); |
|
| 2914 | + if (null !== $filtered) |
|
| 2915 | 2915 | return $filtered; |
| 2916 | 2916 | |
| 2917 | 2917 | $to_ncr = array( |
@@ -3173,7 +3173,7 @@ discard block |
||
| 3173 | 3173 | '♦' => '♦' |
| 3174 | 3174 | ); |
| 3175 | 3175 | |
| 3176 | - return str_replace( array_keys($to_ncr), array_values($to_ncr), $text ); |
|
| 3176 | + return str_replace(array_keys($to_ncr), array_values($to_ncr), $text); |
|
| 3177 | 3177 | } |
| 3178 | 3178 | |
| 3179 | 3179 | /** |
@@ -3190,9 +3190,9 @@ discard block |
||
| 3190 | 3190 | * @param string $text The text to be formatted. |
| 3191 | 3191 | * @return string The formatted text after filter is applied. |
| 3192 | 3192 | */ |
| 3193 | -function format_for_editor( $text, $default_editor = null ) { |
|
| 3194 | - if ( $text ) { |
|
| 3195 | - $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); |
|
| 3193 | +function format_for_editor($text, $default_editor = null) { |
|
| 3194 | + if ($text) { |
|
| 3195 | + $text = htmlspecialchars($text, ENT_NOQUOTES, get_option('blog_charset')); |
|
| 3196 | 3196 | } |
| 3197 | 3197 | |
| 3198 | 3198 | /** |
@@ -3202,7 +3202,7 @@ discard block |
||
| 3202 | 3202 | * |
| 3203 | 3203 | * @param string $text The formatted text. |
| 3204 | 3204 | */ |
| 3205 | - return apply_filters( 'format_for_editor', $text, $default_editor ); |
|
| 3205 | + return apply_filters('format_for_editor', $text, $default_editor); |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | /** |
@@ -3220,12 +3220,12 @@ discard block |
||
| 3220 | 3220 | * @param string $subject The string being searched and replaced on, otherwise known as the haystack. |
| 3221 | 3221 | * @return string The string with the replaced svalues. |
| 3222 | 3222 | */ |
| 3223 | -function _deep_replace( $search, $subject ) { |
|
| 3223 | +function _deep_replace($search, $subject) { |
|
| 3224 | 3224 | $subject = (string) $subject; |
| 3225 | 3225 | |
| 3226 | 3226 | $count = 1; |
| 3227 | - while ( $count ) { |
|
| 3228 | - $subject = str_replace( $search, '', $subject, $count ); |
|
| 3227 | + while ($count) { |
|
| 3228 | + $subject = str_replace($search, '', $subject, $count); |
|
| 3229 | 3229 | } |
| 3230 | 3230 | |
| 3231 | 3231 | return $subject; |
@@ -3245,9 +3245,9 @@ discard block |
||
| 3245 | 3245 | * @param string|array $data Unescaped data |
| 3246 | 3246 | * @return string|array Escaped data |
| 3247 | 3247 | */ |
| 3248 | -function esc_sql( $data ) { |
|
| 3248 | +function esc_sql($data) { |
|
| 3249 | 3249 | global $wpdb; |
| 3250 | - return $wpdb->_escape( $data ); |
|
| 3250 | + return $wpdb->_escape($data); |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | /** |
@@ -3265,13 +3265,13 @@ discard block |
||
| 3265 | 3265 | * @param string $_context Private. Use esc_url_raw() for database usage. |
| 3266 | 3266 | * @return string The cleaned $url after the 'clean_url' filter is applied. |
| 3267 | 3267 | */ |
| 3268 | -function esc_url( $url, $protocols = null, $_context = 'display' ) { |
|
| 3268 | +function esc_url($url, $protocols = null, $_context = 'display') { |
|
| 3269 | 3269 | $original_url = $url; |
| 3270 | 3270 | |
| 3271 | - if ( '' == $url ) |
|
| 3271 | + if ('' == $url) |
|
| 3272 | 3272 | return $url; |
| 3273 | 3273 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); |
| 3274 | - if ( 0 !== stripos( $url, 'mailto:' ) ) { |
|
| 3274 | + if (0 !== stripos($url, 'mailto:')) { |
|
| 3275 | 3275 | $strip = array('%0d', '%0a', '%0D', '%0A'); |
| 3276 | 3276 | $url = _deep_replace($strip, $url); |
| 3277 | 3277 | } |
@@ -3280,24 +3280,24 @@ discard block |
||
| 3280 | 3280 | * presume it needs http:// appended (unless a relative |
| 3281 | 3281 | * link starting with /, # or ? or a php file). |
| 3282 | 3282 | */ |
| 3283 | - if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && |
|
| 3284 | - ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) |
|
| 3285 | - $url = 'http://' . $url; |
|
| 3283 | + if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && |
|
| 3284 | + ! preg_match('/^[a-z0-9-]+?\.php/i', $url)) |
|
| 3285 | + $url = 'http://'.$url; |
|
| 3286 | 3286 | |
| 3287 | 3287 | // Replace ampersands and single quotes only when displaying. |
| 3288 | - if ( 'display' == $_context ) { |
|
| 3289 | - $url = wp_kses_normalize_entities( $url ); |
|
| 3290 | - $url = str_replace( '&', '&', $url ); |
|
| 3291 | - $url = str_replace( "'", ''', $url ); |
|
| 3288 | + if ('display' == $_context) { |
|
| 3289 | + $url = wp_kses_normalize_entities($url); |
|
| 3290 | + $url = str_replace('&', '&', $url); |
|
| 3291 | + $url = str_replace("'", ''', $url); |
|
| 3292 | 3292 | } |
| 3293 | 3293 | |
| 3294 | - if ( '/' === $url[0] ) { |
|
| 3294 | + if ('/' === $url[0]) { |
|
| 3295 | 3295 | $good_protocol_url = $url; |
| 3296 | 3296 | } else { |
| 3297 | - if ( ! is_array( $protocols ) ) |
|
| 3297 | + if ( ! is_array($protocols)) |
|
| 3298 | 3298 | $protocols = wp_allowed_protocols(); |
| 3299 | - $good_protocol_url = wp_kses_bad_protocol( $url, $protocols ); |
|
| 3300 | - if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) |
|
| 3299 | + $good_protocol_url = wp_kses_bad_protocol($url, $protocols); |
|
| 3300 | + if (strtolower($good_protocol_url) != strtolower($url)) |
|
| 3301 | 3301 | return ''; |
| 3302 | 3302 | } |
| 3303 | 3303 | |
@@ -3310,7 +3310,7 @@ discard block |
||
| 3310 | 3310 | * @param string $original_url The URL prior to cleaning. |
| 3311 | 3311 | * @param string $_context If 'display', replace ampersands and single quotes only. |
| 3312 | 3312 | */ |
| 3313 | - return apply_filters( 'clean_url', $good_protocol_url, $original_url, $_context ); |
|
| 3313 | + return apply_filters('clean_url', $good_protocol_url, $original_url, $_context); |
|
| 3314 | 3314 | } |
| 3315 | 3315 | |
| 3316 | 3316 | /** |
@@ -3322,8 +3322,8 @@ discard block |
||
| 3322 | 3322 | * @param array $protocols An array of acceptable protocols. |
| 3323 | 3323 | * @return string The cleaned URL. |
| 3324 | 3324 | */ |
| 3325 | -function esc_url_raw( $url, $protocols = null ) { |
|
| 3326 | - return esc_url( $url, $protocols, 'db' ); |
|
| 3325 | +function esc_url_raw($url, $protocols = null) { |
|
| 3326 | + return esc_url($url, $protocols, 'db'); |
|
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | /** |
@@ -3336,10 +3336,10 @@ discard block |
||
| 3336 | 3336 | * @param string $myHTML The text to be converted. |
| 3337 | 3337 | * @return string Converted text. |
| 3338 | 3338 | */ |
| 3339 | -function htmlentities2( $myHTML ) { |
|
| 3340 | - $translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); |
|
| 3339 | +function htmlentities2($myHTML) { |
|
| 3340 | + $translation_table = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); |
|
| 3341 | 3341 | $translation_table[chr(38)] = '&'; |
| 3342 | - return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) ); |
|
| 3342 | + return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table)); |
|
| 3343 | 3343 | } |
| 3344 | 3344 | |
| 3345 | 3345 | /** |
@@ -3354,12 +3354,12 @@ discard block |
||
| 3354 | 3354 | * @param string $text The text to be escaped. |
| 3355 | 3355 | * @return string Escaped text. |
| 3356 | 3356 | */ |
| 3357 | -function esc_js( $text ) { |
|
| 3358 | - $safe_text = wp_check_invalid_utf8( $text ); |
|
| 3359 | - $safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); |
|
| 3360 | - $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); |
|
| 3361 | - $safe_text = str_replace( "\r", '', $safe_text ); |
|
| 3362 | - $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) ); |
|
| 3357 | +function esc_js($text) { |
|
| 3358 | + $safe_text = wp_check_invalid_utf8($text); |
|
| 3359 | + $safe_text = _wp_specialchars($safe_text, ENT_COMPAT); |
|
| 3360 | + $safe_text = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes($safe_text)); |
|
| 3361 | + $safe_text = str_replace("\r", '', $safe_text); |
|
| 3362 | + $safe_text = str_replace("\n", '\\n', addslashes($safe_text)); |
|
| 3363 | 3363 | /** |
| 3364 | 3364 | * Filter a string cleaned and escaped for output in JavaScript. |
| 3365 | 3365 | * |
@@ -3371,7 +3371,7 @@ discard block |
||
| 3371 | 3371 | * @param string $safe_text The text after it has been escaped. |
| 3372 | 3372 | * @param string $text The text prior to being escaped. |
| 3373 | 3373 | */ |
| 3374 | - return apply_filters( 'js_escape', $safe_text, $text ); |
|
| 3374 | + return apply_filters('js_escape', $safe_text, $text); |
|
| 3375 | 3375 | } |
| 3376 | 3376 | |
| 3377 | 3377 | /** |
@@ -3382,9 +3382,9 @@ discard block |
||
| 3382 | 3382 | * @param string $text |
| 3383 | 3383 | * @return string |
| 3384 | 3384 | */ |
| 3385 | -function esc_html( $text ) { |
|
| 3386 | - $safe_text = wp_check_invalid_utf8( $text ); |
|
| 3387 | - $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
| 3385 | +function esc_html($text) { |
|
| 3386 | + $safe_text = wp_check_invalid_utf8($text); |
|
| 3387 | + $safe_text = _wp_specialchars($safe_text, ENT_QUOTES); |
|
| 3388 | 3388 | /** |
| 3389 | 3389 | * Filter a string cleaned and escaped for output in HTML. |
| 3390 | 3390 | * |
@@ -3396,7 +3396,7 @@ discard block |
||
| 3396 | 3396 | * @param string $safe_text The text after it has been escaped. |
| 3397 | 3397 | * @param string $text The text prior to being escaped. |
| 3398 | 3398 | */ |
| 3399 | - return apply_filters( 'esc_html', $safe_text, $text ); |
|
| 3399 | + return apply_filters('esc_html', $safe_text, $text); |
|
| 3400 | 3400 | } |
| 3401 | 3401 | |
| 3402 | 3402 | /** |
@@ -3407,9 +3407,9 @@ discard block |
||
| 3407 | 3407 | * @param string $text |
| 3408 | 3408 | * @return string |
| 3409 | 3409 | */ |
| 3410 | -function esc_attr( $text ) { |
|
| 3411 | - $safe_text = wp_check_invalid_utf8( $text ); |
|
| 3412 | - $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); |
|
| 3410 | +function esc_attr($text) { |
|
| 3411 | + $safe_text = wp_check_invalid_utf8($text); |
|
| 3412 | + $safe_text = _wp_specialchars($safe_text, ENT_QUOTES); |
|
| 3413 | 3413 | /** |
| 3414 | 3414 | * Filter a string cleaned and escaped for output in an HTML attribute. |
| 3415 | 3415 | * |
@@ -3421,7 +3421,7 @@ discard block |
||
| 3421 | 3421 | * @param string $safe_text The text after it has been escaped. |
| 3422 | 3422 | * @param string $text The text prior to being escaped. |
| 3423 | 3423 | */ |
| 3424 | - return apply_filters( 'attribute_escape', $safe_text, $text ); |
|
| 3424 | + return apply_filters('attribute_escape', $safe_text, $text); |
|
| 3425 | 3425 | } |
| 3426 | 3426 | |
| 3427 | 3427 | /** |
@@ -3432,8 +3432,8 @@ discard block |
||
| 3432 | 3432 | * @param string $text |
| 3433 | 3433 | * @return string |
| 3434 | 3434 | */ |
| 3435 | -function esc_textarea( $text ) { |
|
| 3436 | - $safe_text = htmlspecialchars( $text, ENT_QUOTES, get_option( 'blog_charset' ) ); |
|
| 3435 | +function esc_textarea($text) { |
|
| 3436 | + $safe_text = htmlspecialchars($text, ENT_QUOTES, get_option('blog_charset')); |
|
| 3437 | 3437 | /** |
| 3438 | 3438 | * Filter a string cleaned and escaped for output in a textarea element. |
| 3439 | 3439 | * |
@@ -3442,7 +3442,7 @@ discard block |
||
| 3442 | 3442 | * @param string $safe_text The text after it has been escaped. |
| 3443 | 3443 | * @param string $text The text prior to being escaped. |
| 3444 | 3444 | */ |
| 3445 | - return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
| 3445 | + return apply_filters('esc_textarea', $safe_text, $text); |
|
| 3446 | 3446 | } |
| 3447 | 3447 | |
| 3448 | 3448 | /** |
@@ -3453,8 +3453,8 @@ discard block |
||
| 3453 | 3453 | * @param string $tag_name |
| 3454 | 3454 | * @return string |
| 3455 | 3455 | */ |
| 3456 | -function tag_escape( $tag_name ) { |
|
| 3457 | - $safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) ); |
|
| 3456 | +function tag_escape($tag_name) { |
|
| 3457 | + $safe_tag = strtolower(preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name)); |
|
| 3458 | 3458 | /** |
| 3459 | 3459 | * Filter a string cleaned and escaped for output as an HTML tag. |
| 3460 | 3460 | * |
@@ -3463,7 +3463,7 @@ discard block |
||
| 3463 | 3463 | * @param string $safe_tag The tag name after it has been escaped. |
| 3464 | 3464 | * @param string $tag_name The text before it was escaped. |
| 3465 | 3465 | */ |
| 3466 | - return apply_filters( 'tag_escape', $safe_tag, $tag_name ); |
|
| 3466 | + return apply_filters('tag_escape', $safe_tag, $tag_name); |
|
| 3467 | 3467 | } |
| 3468 | 3468 | |
| 3469 | 3469 | /** |
@@ -3478,8 +3478,8 @@ discard block |
||
| 3478 | 3478 | * @param string $link Full URL path. |
| 3479 | 3479 | * @return string Absolute path. |
| 3480 | 3480 | */ |
| 3481 | -function wp_make_link_relative( $link ) { |
|
| 3482 | - return preg_replace( '|^(https?:)?//[^/]+(/.*)|i', '$2', $link ); |
|
| 3481 | +function wp_make_link_relative($link) { |
|
| 3482 | + return preg_replace('|^(https?:)?//[^/]+(/.*)|i', '$2', $link); |
|
| 3483 | 3483 | } |
| 3484 | 3484 | |
| 3485 | 3485 | /** |
@@ -3496,22 +3496,22 @@ discard block |
||
| 3496 | 3496 | * @param string $value The unsanitised value. |
| 3497 | 3497 | * @return string Sanitized value. |
| 3498 | 3498 | */ |
| 3499 | -function sanitize_option( $option, $value ) { |
|
| 3499 | +function sanitize_option($option, $value) { |
|
| 3500 | 3500 | global $wpdb; |
| 3501 | 3501 | |
| 3502 | 3502 | $original_value = $value; |
| 3503 | 3503 | $error = ''; |
| 3504 | 3504 | |
| 3505 | - switch ( $option ) { |
|
| 3505 | + switch ($option) { |
|
| 3506 | 3506 | case 'admin_email' : |
| 3507 | 3507 | case 'new_admin_email' : |
| 3508 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3509 | - if ( is_wp_error( $value ) ) { |
|
| 3508 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3509 | + if (is_wp_error($value)) { |
|
| 3510 | 3510 | $error = $value->get_error_message(); |
| 3511 | 3511 | } else { |
| 3512 | - $value = sanitize_email( $value ); |
|
| 3513 | - if ( ! is_email( $value ) ) { |
|
| 3514 | - $error = __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ); |
|
| 3512 | + $value = sanitize_email($value); |
|
| 3513 | + if ( ! is_email($value)) { |
|
| 3514 | + $error = __('The email address entered did not appear to be a valid email address. Please enter a valid email address.'); |
|
| 3515 | 3515 | } |
| 3516 | 3516 | } |
| 3517 | 3517 | break; |
@@ -3536,33 +3536,33 @@ discard block |
||
| 3536 | 3536 | case 'users_can_register': |
| 3537 | 3537 | case 'start_of_week': |
| 3538 | 3538 | case 'site_icon': |
| 3539 | - $value = absint( $value ); |
|
| 3539 | + $value = absint($value); |
|
| 3540 | 3540 | break; |
| 3541 | 3541 | |
| 3542 | 3542 | case 'posts_per_page': |
| 3543 | 3543 | case 'posts_per_rss': |
| 3544 | 3544 | $value = (int) $value; |
| 3545 | - if ( empty($value) ) |
|
| 3545 | + if (empty($value)) |
|
| 3546 | 3546 | $value = 1; |
| 3547 | - if ( $value < -1 ) |
|
| 3547 | + if ($value < -1) |
|
| 3548 | 3548 | $value = abs($value); |
| 3549 | 3549 | break; |
| 3550 | 3550 | |
| 3551 | 3551 | case 'default_ping_status': |
| 3552 | 3552 | case 'default_comment_status': |
| 3553 | 3553 | // Options that if not there have 0 value but need to be something like "closed" |
| 3554 | - if ( $value == '0' || $value == '') |
|
| 3554 | + if ($value == '0' || $value == '') |
|
| 3555 | 3555 | $value = 'closed'; |
| 3556 | 3556 | break; |
| 3557 | 3557 | |
| 3558 | 3558 | case 'blogdescription': |
| 3559 | 3559 | case 'blogname': |
| 3560 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3561 | - if ( is_wp_error( $value ) ) { |
|
| 3560 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3561 | + if (is_wp_error($value)) { |
|
| 3562 | 3562 | $error = $value->get_error_message(); |
| 3563 | 3563 | } else { |
| 3564 | - $value = wp_kses_post( $value ); |
|
| 3565 | - $value = esc_html( $value ); |
|
| 3564 | + $value = wp_kses_post($value); |
|
| 3565 | + $value = esc_html($value); |
|
| 3566 | 3566 | } |
| 3567 | 3567 | break; |
| 3568 | 3568 | |
@@ -3572,10 +3572,10 @@ discard block |
||
| 3572 | 3572 | |
| 3573 | 3573 | case 'blog_public': |
| 3574 | 3574 | // This is the value if the settings checkbox is not checked on POST. Don't rely on this. |
| 3575 | - if ( null === $value ) |
|
| 3575 | + if (null === $value) |
|
| 3576 | 3576 | $value = 1; |
| 3577 | 3577 | else |
| 3578 | - $value = intval( $value ); |
|
| 3578 | + $value = intval($value); |
|
| 3579 | 3579 | break; |
| 3580 | 3580 | |
| 3581 | 3581 | case 'date_format': |
@@ -3584,20 +3584,20 @@ discard block |
||
| 3584 | 3584 | case 'mailserver_login': |
| 3585 | 3585 | case 'mailserver_pass': |
| 3586 | 3586 | case 'upload_path': |
| 3587 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3588 | - if ( is_wp_error( $value ) ) { |
|
| 3587 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3588 | + if (is_wp_error($value)) { |
|
| 3589 | 3589 | $error = $value->get_error_message(); |
| 3590 | 3590 | } else { |
| 3591 | - $value = strip_tags( $value ); |
|
| 3592 | - $value = wp_kses_data( $value ); |
|
| 3591 | + $value = strip_tags($value); |
|
| 3592 | + $value = wp_kses_data($value); |
|
| 3593 | 3593 | } |
| 3594 | 3594 | break; |
| 3595 | 3595 | |
| 3596 | 3596 | case 'ping_sites': |
| 3597 | - $value = explode( "\n", $value ); |
|
| 3598 | - $value = array_filter( array_map( 'trim', $value ) ); |
|
| 3599 | - $value = array_filter( array_map( 'esc_url_raw', $value ) ); |
|
| 3600 | - $value = implode( "\n", $value ); |
|
| 3597 | + $value = explode("\n", $value); |
|
| 3598 | + $value = array_filter(array_map('trim', $value)); |
|
| 3599 | + $value = array_filter(array_map('esc_url_raw', $value)); |
|
| 3600 | + $value = implode("\n", $value); |
|
| 3601 | 3601 | break; |
| 3602 | 3602 | |
| 3603 | 3603 | case 'gmt_offset': |
@@ -3605,120 +3605,120 @@ discard block |
||
| 3605 | 3605 | break; |
| 3606 | 3606 | |
| 3607 | 3607 | case 'siteurl': |
| 3608 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3609 | - if ( is_wp_error( $value ) ) { |
|
| 3608 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3609 | + if (is_wp_error($value)) { |
|
| 3610 | 3610 | $error = $value->get_error_message(); |
| 3611 | 3611 | } else { |
| 3612 | - if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
|
| 3613 | - $value = esc_url_raw( $value ); |
|
| 3612 | + if (preg_match('#http(s?)://(.+)#i', $value)) { |
|
| 3613 | + $value = esc_url_raw($value); |
|
| 3614 | 3614 | } else { |
| 3615 | - $error = __( 'The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
|
| 3615 | + $error = __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.'); |
|
| 3616 | 3616 | } |
| 3617 | 3617 | } |
| 3618 | 3618 | break; |
| 3619 | 3619 | |
| 3620 | 3620 | case 'home': |
| 3621 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3622 | - if ( is_wp_error( $value ) ) { |
|
| 3621 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3622 | + if (is_wp_error($value)) { |
|
| 3623 | 3623 | $error = $value->get_error_message(); |
| 3624 | 3624 | } else { |
| 3625 | - if ( preg_match( '#http(s?)://(.+)#i', $value ) ) { |
|
| 3626 | - $value = esc_url_raw( $value ); |
|
| 3625 | + if (preg_match('#http(s?)://(.+)#i', $value)) { |
|
| 3626 | + $value = esc_url_raw($value); |
|
| 3627 | 3627 | } else { |
| 3628 | - $error = __( 'The Site address you entered did not appear to be a valid URL. Please enter a valid URL.' ); |
|
| 3628 | + $error = __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.'); |
|
| 3629 | 3629 | } |
| 3630 | 3630 | } |
| 3631 | 3631 | break; |
| 3632 | 3632 | |
| 3633 | 3633 | case 'WPLANG': |
| 3634 | 3634 | $allowed = get_available_languages(); |
| 3635 | - if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG ) { |
|
| 3635 | + if ( ! is_multisite() && defined('WPLANG') && '' !== WPLANG && 'en_US' !== WPLANG) { |
|
| 3636 | 3636 | $allowed[] = WPLANG; |
| 3637 | 3637 | } |
| 3638 | - if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) { |
|
| 3639 | - $value = get_option( $option ); |
|
| 3638 | + if ( ! in_array($value, $allowed) && ! empty($value)) { |
|
| 3639 | + $value = get_option($option); |
|
| 3640 | 3640 | } |
| 3641 | 3641 | break; |
| 3642 | 3642 | |
| 3643 | 3643 | case 'illegal_names': |
| 3644 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3645 | - if ( is_wp_error( $value ) ) { |
|
| 3644 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3645 | + if (is_wp_error($value)) { |
|
| 3646 | 3646 | $error = $value->get_error_message(); |
| 3647 | 3647 | } else { |
| 3648 | - if ( ! is_array( $value ) ) |
|
| 3649 | - $value = explode( ' ', $value ); |
|
| 3648 | + if ( ! is_array($value)) |
|
| 3649 | + $value = explode(' ', $value); |
|
| 3650 | 3650 | |
| 3651 | - $value = array_values( array_filter( array_map( 'trim', $value ) ) ); |
|
| 3651 | + $value = array_values(array_filter(array_map('trim', $value))); |
|
| 3652 | 3652 | |
| 3653 | - if ( ! $value ) |
|
| 3653 | + if ( ! $value) |
|
| 3654 | 3654 | $value = ''; |
| 3655 | 3655 | } |
| 3656 | 3656 | break; |
| 3657 | 3657 | |
| 3658 | 3658 | case 'limited_email_domains': |
| 3659 | 3659 | case 'banned_email_domains': |
| 3660 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3661 | - if ( is_wp_error( $value ) ) { |
|
| 3660 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3661 | + if (is_wp_error($value)) { |
|
| 3662 | 3662 | $error = $value->get_error_message(); |
| 3663 | 3663 | } else { |
| 3664 | - if ( ! is_array( $value ) ) |
|
| 3665 | - $value = explode( "\n", $value ); |
|
| 3664 | + if ( ! is_array($value)) |
|
| 3665 | + $value = explode("\n", $value); |
|
| 3666 | 3666 | |
| 3667 | - $domains = array_values( array_filter( array_map( 'trim', $value ) ) ); |
|
| 3667 | + $domains = array_values(array_filter(array_map('trim', $value))); |
|
| 3668 | 3668 | $value = array(); |
| 3669 | 3669 | |
| 3670 | - foreach ( $domains as $domain ) { |
|
| 3671 | - if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) { |
|
| 3670 | + foreach ($domains as $domain) { |
|
| 3671 | + if ( ! preg_match('/(--|\.\.)/', $domain) && preg_match('|^([a-zA-Z0-9-\.])+$|', $domain)) { |
|
| 3672 | 3672 | $value[] = $domain; |
| 3673 | 3673 | } |
| 3674 | 3674 | } |
| 3675 | - if ( ! $value ) |
|
| 3675 | + if ( ! $value) |
|
| 3676 | 3676 | $value = ''; |
| 3677 | 3677 | } |
| 3678 | 3678 | break; |
| 3679 | 3679 | |
| 3680 | 3680 | case 'timezone_string': |
| 3681 | 3681 | $allowed_zones = timezone_identifiers_list(); |
| 3682 | - if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) { |
|
| 3683 | - $error = __( 'The timezone you have entered is not valid. Please select a valid timezone.' ); |
|
| 3682 | + if ( ! in_array($value, $allowed_zones) && ! empty($value)) { |
|
| 3683 | + $error = __('The timezone you have entered is not valid. Please select a valid timezone.'); |
|
| 3684 | 3684 | } |
| 3685 | 3685 | break; |
| 3686 | 3686 | |
| 3687 | 3687 | case 'permalink_structure': |
| 3688 | 3688 | case 'category_base': |
| 3689 | 3689 | case 'tag_base': |
| 3690 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3691 | - if ( is_wp_error( $value ) ) { |
|
| 3690 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3691 | + if (is_wp_error($value)) { |
|
| 3692 | 3692 | $error = $value->get_error_message(); |
| 3693 | 3693 | } else { |
| 3694 | - $value = esc_url_raw( $value ); |
|
| 3695 | - $value = str_replace( 'http://', '', $value ); |
|
| 3694 | + $value = esc_url_raw($value); |
|
| 3695 | + $value = str_replace('http://', '', $value); |
|
| 3696 | 3696 | } |
| 3697 | 3697 | break; |
| 3698 | 3698 | |
| 3699 | 3699 | case 'default_role' : |
| 3700 | - if ( ! get_role( $value ) && get_role( 'subscriber' ) ) |
|
| 3700 | + if ( ! get_role($value) && get_role('subscriber')) |
|
| 3701 | 3701 | $value = 'subscriber'; |
| 3702 | 3702 | break; |
| 3703 | 3703 | |
| 3704 | 3704 | case 'moderation_keys': |
| 3705 | 3705 | case 'blacklist_keys': |
| 3706 | - $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value ); |
|
| 3707 | - if ( is_wp_error( $value ) ) { |
|
| 3706 | + $value = $wpdb->strip_invalid_text_for_column($wpdb->options, 'option_value', $value); |
|
| 3707 | + if (is_wp_error($value)) { |
|
| 3708 | 3708 | $error = $value->get_error_message(); |
| 3709 | 3709 | } else { |
| 3710 | - $value = explode( "\n", $value ); |
|
| 3711 | - $value = array_filter( array_map( 'trim', $value ) ); |
|
| 3712 | - $value = array_unique( $value ); |
|
| 3713 | - $value = implode( "\n", $value ); |
|
| 3710 | + $value = explode("\n", $value); |
|
| 3711 | + $value = array_filter(array_map('trim', $value)); |
|
| 3712 | + $value = array_unique($value); |
|
| 3713 | + $value = implode("\n", $value); |
|
| 3714 | 3714 | } |
| 3715 | 3715 | break; |
| 3716 | 3716 | } |
| 3717 | 3717 | |
| 3718 | - if ( ! empty( $error ) ) { |
|
| 3719 | - $value = get_option( $option ); |
|
| 3720 | - if ( function_exists( 'add_settings_error' ) ) { |
|
| 3721 | - add_settings_error( $option, "invalid_{$option}", $error ); |
|
| 3718 | + if ( ! empty($error)) { |
|
| 3719 | + $value = get_option($option); |
|
| 3720 | + if (function_exists('add_settings_error')) { |
|
| 3721 | + add_settings_error($option, "invalid_{$option}", $error); |
|
| 3722 | 3722 | } |
| 3723 | 3723 | } |
| 3724 | 3724 | |
@@ -3732,7 +3732,7 @@ discard block |
||
| 3732 | 3732 | * @param string $option The option name. |
| 3733 | 3733 | * @param string $original_value The original value passed to the function. |
| 3734 | 3734 | */ |
| 3735 | - return apply_filters( "sanitize_option_{$option}", $value, $option, $original_value ); |
|
| 3735 | + return apply_filters("sanitize_option_{$option}", $value, $option, $original_value); |
|
| 3736 | 3736 | } |
| 3737 | 3737 | |
| 3738 | 3738 | /** |
@@ -3746,10 +3746,10 @@ discard block |
||
| 3746 | 3746 | * @param string $string The string to be parsed. |
| 3747 | 3747 | * @param array $array Variables will be stored in this array. |
| 3748 | 3748 | */ |
| 3749 | -function wp_parse_str( $string, &$array ) { |
|
| 3750 | - parse_str( $string, $array ); |
|
| 3751 | - if ( get_magic_quotes_gpc() ) |
|
| 3752 | - $array = stripslashes_deep( $array ); |
|
| 3749 | +function wp_parse_str($string, &$array) { |
|
| 3750 | + parse_str($string, $array); |
|
| 3751 | + if (get_magic_quotes_gpc()) |
|
| 3752 | + $array = stripslashes_deep($array); |
|
| 3753 | 3753 | /** |
| 3754 | 3754 | * Filter the array of variables derived from a parsed string. |
| 3755 | 3755 | * |
@@ -3757,7 +3757,7 @@ discard block |
||
| 3757 | 3757 | * |
| 3758 | 3758 | * @param array $array The array populated with variables. |
| 3759 | 3759 | */ |
| 3760 | - $array = apply_filters( 'wp_parse_str', $array ); |
|
| 3760 | + $array = apply_filters('wp_parse_str', $array); |
|
| 3761 | 3761 | } |
| 3762 | 3762 | |
| 3763 | 3763 | /** |
@@ -3770,7 +3770,7 @@ discard block |
||
| 3770 | 3770 | * @param string $text Text to be converted. |
| 3771 | 3771 | * @return string Converted text. |
| 3772 | 3772 | */ |
| 3773 | -function wp_pre_kses_less_than( $text ) { |
|
| 3773 | +function wp_pre_kses_less_than($text) { |
|
| 3774 | 3774 | return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text); |
| 3775 | 3775 | } |
| 3776 | 3776 | |
@@ -3782,8 +3782,8 @@ discard block |
||
| 3782 | 3782 | * @param array $matches Populated by matches to preg_replace. |
| 3783 | 3783 | * @return string The text returned after esc_html if needed. |
| 3784 | 3784 | */ |
| 3785 | -function wp_pre_kses_less_than_callback( $matches ) { |
|
| 3786 | - if ( false === strpos($matches[0], '>') ) |
|
| 3785 | +function wp_pre_kses_less_than_callback($matches) { |
|
| 3786 | + if (false === strpos($matches[0], '>')) |
|
| 3787 | 3787 | return esc_html($matches[0]); |
| 3788 | 3788 | return $matches[0]; |
| 3789 | 3789 | } |
@@ -3798,21 +3798,21 @@ discard block |
||
| 3798 | 3798 | * @param mixed $args ,... Arguments to be formatted into the $pattern string. |
| 3799 | 3799 | * @return string The formatted string. |
| 3800 | 3800 | */ |
| 3801 | -function wp_sprintf( $pattern ) { |
|
| 3801 | +function wp_sprintf($pattern) { |
|
| 3802 | 3802 | $args = func_get_args(); |
| 3803 | 3803 | $len = strlen($pattern); |
| 3804 | 3804 | $start = 0; |
| 3805 | 3805 | $result = ''; |
| 3806 | 3806 | $arg_index = 0; |
| 3807 | - while ( $len > $start ) { |
|
| 3807 | + while ($len > $start) { |
|
| 3808 | 3808 | // Last character: append and break |
| 3809 | - if ( strlen($pattern) - 1 == $start ) { |
|
| 3809 | + if (strlen($pattern) - 1 == $start) { |
|
| 3810 | 3810 | $result .= substr($pattern, -1); |
| 3811 | 3811 | break; |
| 3812 | 3812 | } |
| 3813 | 3813 | |
| 3814 | 3814 | // Literal %: append and continue |
| 3815 | - if ( substr($pattern, $start, 2) == '%%' ) { |
|
| 3815 | + if (substr($pattern, $start, 2) == '%%') { |
|
| 3816 | 3816 | $start += 2; |
| 3817 | 3817 | $result .= '%'; |
| 3818 | 3818 | continue; |
@@ -3820,14 +3820,14 @@ discard block |
||
| 3820 | 3820 | |
| 3821 | 3821 | // Get fragment before next % |
| 3822 | 3822 | $end = strpos($pattern, '%', $start + 1); |
| 3823 | - if ( false === $end ) |
|
| 3823 | + if (false === $end) |
|
| 3824 | 3824 | $end = $len; |
| 3825 | 3825 | $fragment = substr($pattern, $start, $end - $start); |
| 3826 | 3826 | |
| 3827 | 3827 | // Fragment has a specifier |
| 3828 | - if ( $pattern[$start] == '%' ) { |
|
| 3828 | + if ($pattern[$start] == '%') { |
|
| 3829 | 3829 | // Find numbered arguments or take the next one in order |
| 3830 | - if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { |
|
| 3830 | + if (preg_match('/^%(\d+)\$/', $fragment, $matches)) { |
|
| 3831 | 3831 | $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; |
| 3832 | 3832 | $fragment = str_replace("%{$matches[1]}$", '%', $fragment); |
| 3833 | 3833 | } else { |
@@ -3845,11 +3845,11 @@ discard block |
||
| 3845 | 3845 | * @param string $fragment A fragment from the pattern. |
| 3846 | 3846 | * @param string $arg The argument. |
| 3847 | 3847 | */ |
| 3848 | - $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); |
|
| 3849 | - if ( $_fragment != $fragment ) |
|
| 3848 | + $_fragment = apply_filters('wp_sprintf', $fragment, $arg); |
|
| 3849 | + if ($_fragment != $fragment) |
|
| 3850 | 3850 | $fragment = $_fragment; |
| 3851 | 3851 | else |
| 3852 | - $fragment = sprintf($fragment, strval($arg) ); |
|
| 3852 | + $fragment = sprintf($fragment, strval($arg)); |
|
| 3853 | 3853 | } |
| 3854 | 3854 | |
| 3855 | 3855 | // Append to result and move to next fragment |
@@ -3872,13 +3872,13 @@ discard block |
||
| 3872 | 3872 | * @param array $args List items to prepend to the content and replace '%l'. |
| 3873 | 3873 | * @return string Localized list items and rest of the content. |
| 3874 | 3874 | */ |
| 3875 | -function wp_sprintf_l( $pattern, $args ) { |
|
| 3875 | +function wp_sprintf_l($pattern, $args) { |
|
| 3876 | 3876 | // Not a match |
| 3877 | - if ( substr($pattern, 0, 2) != '%l' ) |
|
| 3877 | + if (substr($pattern, 0, 2) != '%l') |
|
| 3878 | 3878 | return $pattern; |
| 3879 | 3879 | |
| 3880 | 3880 | // Nothing to work with |
| 3881 | - if ( empty($args) ) |
|
| 3881 | + if (empty($args)) |
|
| 3882 | 3882 | return ''; |
| 3883 | 3883 | |
| 3884 | 3884 | /** |
@@ -3892,30 +3892,30 @@ discard block |
||
| 3892 | 3892 | * |
| 3893 | 3893 | * @param array $delimiters An array of translated delimiters. |
| 3894 | 3894 | */ |
| 3895 | - $l = apply_filters( 'wp_sprintf_l', array( |
|
| 3895 | + $l = apply_filters('wp_sprintf_l', array( |
|
| 3896 | 3896 | /* translators: used to join items in a list with more than 2 items */ |
| 3897 | - 'between' => sprintf( __('%s, %s'), '', '' ), |
|
| 3897 | + 'between' => sprintf(__('%s, %s'), '', ''), |
|
| 3898 | 3898 | /* translators: used to join last two items in a list with more than 2 times */ |
| 3899 | - 'between_last_two' => sprintf( __('%s, and %s'), '', '' ), |
|
| 3899 | + 'between_last_two' => sprintf(__('%s, and %s'), '', ''), |
|
| 3900 | 3900 | /* translators: used to join items in a list with only 2 items */ |
| 3901 | - 'between_only_two' => sprintf( __('%s and %s'), '', '' ), |
|
| 3902 | - ) ); |
|
| 3901 | + 'between_only_two' => sprintf(__('%s and %s'), '', ''), |
|
| 3902 | + )); |
|
| 3903 | 3903 | |
| 3904 | 3904 | $args = (array) $args; |
| 3905 | 3905 | $result = array_shift($args); |
| 3906 | - if ( count($args) == 1 ) |
|
| 3907 | - $result .= $l['between_only_two'] . array_shift($args); |
|
| 3906 | + if (count($args) == 1) |
|
| 3907 | + $result .= $l['between_only_two'].array_shift($args); |
|
| 3908 | 3908 | // Loop when more than two args |
| 3909 | 3909 | $i = count($args); |
| 3910 | - while ( $i ) { |
|
| 3910 | + while ($i) { |
|
| 3911 | 3911 | $arg = array_shift($args); |
| 3912 | 3912 | $i--; |
| 3913 | - if ( 0 == $i ) |
|
| 3914 | - $result .= $l['between_last_two'] . $arg; |
|
| 3913 | + if (0 == $i) |
|
| 3914 | + $result .= $l['between_last_two'].$arg; |
|
| 3915 | 3915 | else |
| 3916 | - $result .= $l['between'] . $arg; |
|
| 3916 | + $result .= $l['between'].$arg; |
|
| 3917 | 3917 | } |
| 3918 | - return $result . substr($pattern, 2); |
|
| 3918 | + return $result.substr($pattern, 2); |
|
| 3919 | 3919 | } |
| 3920 | 3920 | |
| 3921 | 3921 | /** |
@@ -3932,15 +3932,15 @@ discard block |
||
| 3932 | 3932 | * @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string. |
| 3933 | 3933 | * @return string The excerpt. |
| 3934 | 3934 | */ |
| 3935 | -function wp_html_excerpt( $str, $count, $more = null ) { |
|
| 3936 | - if ( null === $more ) |
|
| 3935 | +function wp_html_excerpt($str, $count, $more = null) { |
|
| 3936 | + if (null === $more) |
|
| 3937 | 3937 | $more = ''; |
| 3938 | - $str = wp_strip_all_tags( $str, true ); |
|
| 3939 | - $excerpt = mb_substr( $str, 0, $count ); |
|
| 3938 | + $str = wp_strip_all_tags($str, true); |
|
| 3939 | + $excerpt = mb_substr($str, 0, $count); |
|
| 3940 | 3940 | // remove part of an entity at the end |
| 3941 | - $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); |
|
| 3942 | - if ( $str != $excerpt ) |
|
| 3943 | - $excerpt = trim( $excerpt ) . $more; |
|
| 3941 | + $excerpt = preg_replace('/&[^;\s]{0,6}$/', '', $excerpt); |
|
| 3942 | + if ($str != $excerpt) |
|
| 3943 | + $excerpt = trim($excerpt).$more; |
|
| 3944 | 3944 | return $excerpt; |
| 3945 | 3945 | } |
| 3946 | 3946 | |
@@ -3959,11 +3959,11 @@ discard block |
||
| 3959 | 3959 | * @param array $attrs The attributes which should be processed. |
| 3960 | 3960 | * @return string The processed content. |
| 3961 | 3961 | */ |
| 3962 | -function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { |
|
| 3962 | +function links_add_base_url($content, $base, $attrs = array('src', 'href')) { |
|
| 3963 | 3963 | global $_links_add_base; |
| 3964 | 3964 | $_links_add_base = $base; |
| 3965 | - $attrs = implode('|', (array)$attrs); |
|
| 3966 | - return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); |
|
| 3965 | + $attrs = implode('|', (array) $attrs); |
|
| 3966 | + return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content); |
|
| 3967 | 3967 | } |
| 3968 | 3968 | |
| 3969 | 3969 | /** |
@@ -3977,13 +3977,12 @@ discard block |
||
| 3977 | 3977 | * @param string $m The matched link. |
| 3978 | 3978 | * @return string The processed link. |
| 3979 | 3979 | */ |
| 3980 | -function _links_add_base( $m ) { |
|
| 3980 | +function _links_add_base($m) { |
|
| 3981 | 3981 | global $_links_add_base; |
| 3982 | 3982 | //1 = attribute name 2 = quotation mark 3 = URL |
| 3983 | - return $m[1] . '=' . $m[2] . |
|
| 3984 | - ( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ? |
|
| 3985 | - $m[3] : |
|
| 3986 | - WP_HTTP::make_absolute_url( $m[3], $_links_add_base ) |
|
| 3983 | + return $m[1].'='.$m[2]. |
|
| 3984 | + (preg_match('#^(\w{1,20}):#', $m[3], $protocol) && in_array($protocol[1], wp_allowed_protocols()) ? |
|
| 3985 | + $m[3] : WP_HTTP::make_absolute_url($m[3], $_links_add_base) |
|
| 3987 | 3986 | ) |
| 3988 | 3987 | . $m[2]; |
| 3989 | 3988 | } |
@@ -4005,11 +4004,11 @@ discard block |
||
| 4005 | 4004 | * @param array $tags An array of tags to apply to. |
| 4006 | 4005 | * @return string The processed content. |
| 4007 | 4006 | */ |
| 4008 | -function links_add_target( $content, $target = '_blank', $tags = array('a') ) { |
|
| 4007 | +function links_add_target($content, $target = '_blank', $tags = array('a')) { |
|
| 4009 | 4008 | global $_links_add_target; |
| 4010 | 4009 | $_links_add_target = $target; |
| 4011 | - $tags = implode('|', (array)$tags); |
|
| 4012 | - return preg_replace_callback( "!<($tags)([^>]*)>!i", '_links_add_target', $content ); |
|
| 4010 | + $tags = implode('|', (array) $tags); |
|
| 4011 | + return preg_replace_callback("!<($tags)([^>]*)>!i", '_links_add_target', $content); |
|
| 4013 | 4012 | } |
| 4014 | 4013 | |
| 4015 | 4014 | /** |
@@ -4023,11 +4022,11 @@ discard block |
||
| 4023 | 4022 | * @param string $m The matched link. |
| 4024 | 4023 | * @return string The processed link. |
| 4025 | 4024 | */ |
| 4026 | -function _links_add_target( $m ) { |
|
| 4025 | +function _links_add_target($m) { |
|
| 4027 | 4026 | global $_links_add_target; |
| 4028 | 4027 | $tag = $m[1]; |
| 4029 | 4028 | $link = preg_replace('|( target=([\'"])(.*?)\2)|i', '', $m[2]); |
| 4030 | - return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; |
|
| 4029 | + return '<'.$tag.$link.' target="'.esc_attr($_links_add_target).'">'; |
|
| 4031 | 4030 | } |
| 4032 | 4031 | |
| 4033 | 4032 | /** |
@@ -4038,10 +4037,10 @@ discard block |
||
| 4038 | 4037 | * @param string $str The string to normalize. |
| 4039 | 4038 | * @return string The normalized string. |
| 4040 | 4039 | */ |
| 4041 | -function normalize_whitespace( $str ) { |
|
| 4042 | - $str = trim( $str ); |
|
| 4043 | - $str = str_replace( "\r", "\n", $str ); |
|
| 4044 | - $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); |
|
| 4040 | +function normalize_whitespace($str) { |
|
| 4041 | + $str = trim($str); |
|
| 4042 | + $str = str_replace("\r", "\n", $str); |
|
| 4043 | + $str = preg_replace(array('/\n+/', '/[ \t]+/'), array("\n", ' '), $str); |
|
| 4045 | 4044 | return $str; |
| 4046 | 4045 | } |
| 4047 | 4046 | |
@@ -4059,13 +4058,13 @@ discard block |
||
| 4059 | 4058 | * @return string The processed string. |
| 4060 | 4059 | */ |
| 4061 | 4060 | function wp_strip_all_tags($string, $remove_breaks = false) { |
| 4062 | - $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); |
|
| 4061 | + $string = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string); |
|
| 4063 | 4062 | $string = strip_tags($string); |
| 4064 | 4063 | |
| 4065 | - if ( $remove_breaks ) |
|
| 4064 | + if ($remove_breaks) |
|
| 4066 | 4065 | $string = preg_replace('/[\r\n\t ]+/', ' ', $string); |
| 4067 | 4066 | |
| 4068 | - return trim( $string ); |
|
| 4067 | + return trim($string); |
|
| 4069 | 4068 | } |
| 4070 | 4069 | |
| 4071 | 4070 | /** |
@@ -4082,26 +4081,26 @@ discard block |
||
| 4082 | 4081 | * @param string $str |
| 4083 | 4082 | * @return string |
| 4084 | 4083 | */ |
| 4085 | -function sanitize_text_field( $str ) { |
|
| 4086 | - $filtered = wp_check_invalid_utf8( $str ); |
|
| 4084 | +function sanitize_text_field($str) { |
|
| 4085 | + $filtered = wp_check_invalid_utf8($str); |
|
| 4087 | 4086 | |
| 4088 | - if ( strpos($filtered, '<') !== false ) { |
|
| 4089 | - $filtered = wp_pre_kses_less_than( $filtered ); |
|
| 4087 | + if (strpos($filtered, '<') !== false) { |
|
| 4088 | + $filtered = wp_pre_kses_less_than($filtered); |
|
| 4090 | 4089 | // This will strip extra whitespace for us. |
| 4091 | - $filtered = wp_strip_all_tags( $filtered, true ); |
|
| 4090 | + $filtered = wp_strip_all_tags($filtered, true); |
|
| 4092 | 4091 | } else { |
| 4093 | - $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filtered) ); |
|
| 4092 | + $filtered = trim(preg_replace('/[\r\n\t ]+/', ' ', $filtered)); |
|
| 4094 | 4093 | } |
| 4095 | 4094 | |
| 4096 | 4095 | $found = false; |
| 4097 | - while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) { |
|
| 4096 | + while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) { |
|
| 4098 | 4097 | $filtered = str_replace($match[0], '', $filtered); |
| 4099 | 4098 | $found = true; |
| 4100 | 4099 | } |
| 4101 | 4100 | |
| 4102 | - if ( $found ) { |
|
| 4101 | + if ($found) { |
|
| 4103 | 4102 | // Strip out the whitespace that may now exist after removing the octets. |
| 4104 | - $filtered = trim( preg_replace('/ +/', ' ', $filtered) ); |
|
| 4103 | + $filtered = trim(preg_replace('/ +/', ' ', $filtered)); |
|
| 4105 | 4104 | } |
| 4106 | 4105 | |
| 4107 | 4106 | /** |
@@ -4112,7 +4111,7 @@ discard block |
||
| 4112 | 4111 | * @param string $filtered The sanitized string. |
| 4113 | 4112 | * @param string $str The string prior to being sanitized. |
| 4114 | 4113 | */ |
| 4115 | - return apply_filters( 'sanitize_text_field', $filtered, $str ); |
|
| 4114 | + return apply_filters('sanitize_text_field', $filtered, $str); |
|
| 4116 | 4115 | } |
| 4117 | 4116 | |
| 4118 | 4117 | /** |
@@ -4124,8 +4123,8 @@ discard block |
||
| 4124 | 4123 | * @param string $suffix If the filename ends in suffix this will also be cut off. |
| 4125 | 4124 | * @return string |
| 4126 | 4125 | */ |
| 4127 | -function wp_basename( $path, $suffix = '' ) { |
|
| 4128 | - return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); |
|
| 4126 | +function wp_basename($path, $suffix = '') { |
|
| 4127 | + return urldecode(basename(str_replace(array('%2F', '%5C'), '/', urlencode($path)), $suffix)); |
|
| 4129 | 4128 | } |
| 4130 | 4129 | |
| 4131 | 4130 | /** |
@@ -4137,19 +4136,19 @@ discard block |
||
| 4137 | 4136 | * |
| 4138 | 4137 | * @staticvar string|false $dblq |
| 4139 | 4138 | */ |
| 4140 | -function capital_P_dangit( $text ) { |
|
| 4139 | +function capital_P_dangit($text) { |
|
| 4141 | 4140 | // Simple replacement for titles |
| 4142 | 4141 | $current_filter = current_filter(); |
| 4143 | - if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) |
|
| 4144 | - return str_replace( 'Wordpress', 'WordPress', $text ); |
|
| 4142 | + if ('the_title' === $current_filter || 'wp_title' === $current_filter) |
|
| 4143 | + return str_replace('Wordpress', 'WordPress', $text); |
|
| 4145 | 4144 | // Still here? Use the more judicious replacement |
| 4146 | 4145 | static $dblq = false; |
| 4147 | - if ( false === $dblq ) { |
|
| 4148 | - $dblq = _x( '“', 'opening curly double quote' ); |
|
| 4146 | + if (false === $dblq) { |
|
| 4147 | + $dblq = _x('“', 'opening curly double quote'); |
|
| 4149 | 4148 | } |
| 4150 | 4149 | return str_replace( |
| 4151 | - array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), |
|
| 4152 | - array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), |
|
| 4150 | + array(' Wordpress', '‘Wordpress', $dblq.'Wordpress', '>Wordpress', '(Wordpress'), |
|
| 4151 | + array(' WordPress', '‘WordPress', $dblq.'WordPress', '>WordPress', '(WordPress'), |
|
| 4153 | 4152 | $text ); |
| 4154 | 4153 | } |
| 4155 | 4154 | |
@@ -4161,8 +4160,8 @@ discard block |
||
| 4161 | 4160 | * @param string $mime_type Mime type |
| 4162 | 4161 | * @return string Sanitized mime type |
| 4163 | 4162 | */ |
| 4164 | -function sanitize_mime_type( $mime_type ) { |
|
| 4165 | - $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); |
|
| 4163 | +function sanitize_mime_type($mime_type) { |
|
| 4164 | + $sani_mime_type = preg_replace('/[^-+*.a-zA-Z0-9\/]/', '', $mime_type); |
|
| 4166 | 4165 | /** |
| 4167 | 4166 | * Filter a mime type following sanitization. |
| 4168 | 4167 | * |
@@ -4171,7 +4170,7 @@ discard block |
||
| 4171 | 4170 | * @param string $sani_mime_type The sanitized mime type. |
| 4172 | 4171 | * @param string $mime_type The mime type prior to sanitization. |
| 4173 | 4172 | */ |
| 4174 | - return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); |
|
| 4173 | + return apply_filters('sanitize_mime_type', $sani_mime_type, $mime_type); |
|
| 4175 | 4174 | } |
| 4176 | 4175 | |
| 4177 | 4176 | /** |
@@ -4182,14 +4181,14 @@ discard block |
||
| 4182 | 4181 | * @param string $to_ping Space or carriage return separated URLs |
| 4183 | 4182 | * @return string URLs starting with the http or https protocol, separated by a carriage return. |
| 4184 | 4183 | */ |
| 4185 | -function sanitize_trackback_urls( $to_ping ) { |
|
| 4186 | - $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); |
|
| 4187 | - foreach ( $urls_to_ping as $k => $url ) { |
|
| 4188 | - if ( !preg_match( '#^https?://.#i', $url ) ) |
|
| 4189 | - unset( $urls_to_ping[$k] ); |
|
| 4184 | +function sanitize_trackback_urls($to_ping) { |
|
| 4185 | + $urls_to_ping = preg_split('/[\r\n\t ]/', trim($to_ping), -1, PREG_SPLIT_NO_EMPTY); |
|
| 4186 | + foreach ($urls_to_ping as $k => $url) { |
|
| 4187 | + if ( ! preg_match('#^https?://.#i', $url)) |
|
| 4188 | + unset($urls_to_ping[$k]); |
|
| 4190 | 4189 | } |
| 4191 | - $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); |
|
| 4192 | - $urls_to_ping = implode( "\n", $urls_to_ping ); |
|
| 4190 | + $urls_to_ping = array_map('esc_url_raw', $urls_to_ping); |
|
| 4191 | + $urls_to_ping = implode("\n", $urls_to_ping); |
|
| 4193 | 4192 | /** |
| 4194 | 4193 | * Filter a list of trackback URLs following sanitization. |
| 4195 | 4194 | * |
@@ -4201,7 +4200,7 @@ discard block |
||
| 4201 | 4200 | * @param string $urls_to_ping Sanitized space or carriage return separated URLs. |
| 4202 | 4201 | * @param string $to_ping Space or carriage return separated URLs before sanitization. |
| 4203 | 4202 | */ |
| 4204 | - return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); |
|
| 4203 | + return apply_filters('sanitize_trackback_urls', $urls_to_ping, $to_ping); |
|
| 4205 | 4204 | } |
| 4206 | 4205 | |
| 4207 | 4206 | /** |
@@ -4215,17 +4214,17 @@ discard block |
||
| 4215 | 4214 | * @param string|array $value String or array of strings to slash. |
| 4216 | 4215 | * @return string|array Slashed $value |
| 4217 | 4216 | */ |
| 4218 | -function wp_slash( $value ) { |
|
| 4219 | - if ( is_array( $value ) ) { |
|
| 4220 | - foreach ( $value as $k => $v ) { |
|
| 4221 | - if ( is_array( $v ) ) { |
|
| 4222 | - $value[$k] = wp_slash( $v ); |
|
| 4217 | +function wp_slash($value) { |
|
| 4218 | + if (is_array($value)) { |
|
| 4219 | + foreach ($value as $k => $v) { |
|
| 4220 | + if (is_array($v)) { |
|
| 4221 | + $value[$k] = wp_slash($v); |
|
| 4223 | 4222 | } else { |
| 4224 | - $value[$k] = addslashes( $v ); |
|
| 4223 | + $value[$k] = addslashes($v); |
|
| 4225 | 4224 | } |
| 4226 | 4225 | } |
| 4227 | 4226 | } else { |
| 4228 | - $value = addslashes( $value ); |
|
| 4227 | + $value = addslashes($value); |
|
| 4229 | 4228 | } |
| 4230 | 4229 | |
| 4231 | 4230 | return $value; |
@@ -4242,8 +4241,8 @@ discard block |
||
| 4242 | 4241 | * @param string|array $value String or array of strings to unslash. |
| 4243 | 4242 | * @return string|array Unslashed $value |
| 4244 | 4243 | */ |
| 4245 | -function wp_unslash( $value ) { |
|
| 4246 | - return stripslashes_deep( $value ); |
|
| 4244 | +function wp_unslash($value) { |
|
| 4245 | + return stripslashes_deep($value); |
|
| 4247 | 4246 | } |
| 4248 | 4247 | |
| 4249 | 4248 | /** |
@@ -4254,13 +4253,13 @@ discard block |
||
| 4254 | 4253 | * @param string $content A string which might contain a URL. |
| 4255 | 4254 | * @return string|false The found URL. |
| 4256 | 4255 | */ |
| 4257 | -function get_url_in_content( $content ) { |
|
| 4258 | - if ( empty( $content ) ) { |
|
| 4256 | +function get_url_in_content($content) { |
|
| 4257 | + if (empty($content)) { |
|
| 4259 | 4258 | return false; |
| 4260 | 4259 | } |
| 4261 | 4260 | |
| 4262 | - if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { |
|
| 4263 | - return esc_url_raw( $matches[2] ); |
|
| 4261 | + if (preg_match('/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches)) { |
|
| 4262 | + return esc_url_raw($matches[2]); |
|
| 4264 | 4263 | } |
| 4265 | 4264 | |
| 4266 | 4265 | return false; |
@@ -4282,7 +4281,7 @@ discard block |
||
| 4282 | 4281 | function wp_spaces_regexp() { |
| 4283 | 4282 | static $spaces = ''; |
| 4284 | 4283 | |
| 4285 | - if ( empty( $spaces ) ) { |
|
| 4284 | + if (empty($spaces)) { |
|
| 4286 | 4285 | /** |
| 4287 | 4286 | * Filter the regexp for common whitespace characters. |
| 4288 | 4287 | * |
@@ -4295,7 +4294,7 @@ discard block |
||
| 4295 | 4294 | * |
| 4296 | 4295 | * @param string $spaces Regexp pattern for matching common whitespace characters. |
| 4297 | 4296 | */ |
| 4298 | - $spaces = apply_filters( 'wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| ' ); |
|
| 4297 | + $spaces = apply_filters('wp_spaces_regexp', '[\r\n\t ]|\xC2\xA0| '); |
|
| 4299 | 4298 | } |
| 4300 | 4299 | |
| 4301 | 4300 | return $spaces; |
@@ -4311,7 +4310,7 @@ discard block |
||
| 4311 | 4310 | function print_emoji_styles() { |
| 4312 | 4311 | static $printed = false; |
| 4313 | 4312 | |
| 4314 | - if ( $printed ) { |
|
| 4313 | + if ($printed) { |
|
| 4315 | 4314 | return; |
| 4316 | 4315 | } |
| 4317 | 4316 | |
@@ -4343,7 +4342,7 @@ discard block |
||
| 4343 | 4342 | global $wp_version; |
| 4344 | 4343 | static $printed = false; |
| 4345 | 4344 | |
| 4346 | - if ( $printed ) { |
|
| 4345 | + if ($printed) { |
|
| 4347 | 4346 | return; |
| 4348 | 4347 | } |
| 4349 | 4348 | |
@@ -4357,7 +4356,7 @@ discard block |
||
| 4357 | 4356 | * |
| 4358 | 4357 | * @param string The emoji base URL. |
| 4359 | 4358 | */ |
| 4360 | - 'baseUrl' => apply_filters( 'emoji_url', set_url_scheme( '//s.w.org/images/core/emoji/72x72/' ) ), |
|
| 4359 | + 'baseUrl' => apply_filters('emoji_url', set_url_scheme('//s.w.org/images/core/emoji/72x72/')), |
|
| 4361 | 4360 | |
| 4362 | 4361 | /** |
| 4363 | 4362 | * Filter the extension of the emoji files. |
@@ -4366,29 +4365,29 @@ discard block |
||
| 4366 | 4365 | * |
| 4367 | 4366 | * @param string The emoji extension. Default .png. |
| 4368 | 4367 | */ |
| 4369 | - 'ext' => apply_filters( 'emoji_ext', '.png' ), |
|
| 4368 | + 'ext' => apply_filters('emoji_ext', '.png'), |
|
| 4370 | 4369 | ); |
| 4371 | 4370 | |
| 4372 | - $version = 'ver=' . $wp_version; |
|
| 4371 | + $version = 'ver='.$wp_version; |
|
| 4373 | 4372 | |
| 4374 | - if ( SCRIPT_DEBUG ) { |
|
| 4373 | + if (SCRIPT_DEBUG) { |
|
| 4375 | 4374 | $settings['source'] = array( |
| 4376 | 4375 | /** This filter is documented in wp-includes/class.wp-scripts.php */ |
| 4377 | - 'wpemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji.js?$version" ), 'wpemoji' ), |
|
| 4376 | + 'wpemoji' => apply_filters('script_loader_src', includes_url("js/wp-emoji.js?$version"), 'wpemoji'), |
|
| 4378 | 4377 | /** This filter is documented in wp-includes/class.wp-scripts.php */ |
| 4379 | - 'twemoji' => apply_filters( 'script_loader_src', includes_url( "js/twemoji.js?$version" ), 'twemoji' ), |
|
| 4378 | + 'twemoji' => apply_filters('script_loader_src', includes_url("js/twemoji.js?$version"), 'twemoji'), |
|
| 4380 | 4379 | ); |
| 4381 | 4380 | |
| 4382 | 4381 | ?> |
| 4383 | 4382 | <script type="text/javascript"> |
| 4384 | - window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
| 4385 | - <?php readfile( ABSPATH . WPINC . "/js/wp-emoji-loader.js" ); ?> |
|
| 4383 | + window._wpemojiSettings = <?php echo wp_json_encode($settings); ?>; |
|
| 4384 | + <?php readfile(ABSPATH.WPINC."/js/wp-emoji-loader.js"); ?> |
|
| 4386 | 4385 | </script> |
| 4387 | 4386 | <?php |
| 4388 | 4387 | } else { |
| 4389 | 4388 | $settings['source'] = array( |
| 4390 | 4389 | /** This filter is documented in wp-includes/class.wp-scripts.php */ |
| 4391 | - 'concatemoji' => apply_filters( 'script_loader_src', includes_url( "js/wp-emoji-release.min.js?$version" ), 'concatemoji' ), |
|
| 4390 | + 'concatemoji' => apply_filters('script_loader_src', includes_url("js/wp-emoji-release.min.js?$version"), 'concatemoji'), |
|
| 4392 | 4391 | ); |
| 4393 | 4392 | |
| 4394 | 4393 | /* |
@@ -4403,7 +4402,7 @@ discard block |
||
| 4403 | 4402 | */ |
| 4404 | 4403 | ?> |
| 4405 | 4404 | <script type="text/javascript"> |
| 4406 | - window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; |
|
| 4405 | + window._wpemojiSettings = <?php echo wp_json_encode($settings); ?>; |
|
| 4407 | 4406 | include "js/wp-emoji-loader.min.js" |
| 4408 | 4407 | </script> |
| 4409 | 4408 | <?php |
@@ -4423,8 +4422,8 @@ discard block |
||
| 4423 | 4422 | * @param string $content The content to encode. |
| 4424 | 4423 | * @return string The encoded content. |
| 4425 | 4424 | */ |
| 4426 | -function wp_encode_emoji( $content ) { |
|
| 4427 | - if ( function_exists( 'mb_convert_encoding' ) ) { |
|
| 4425 | +function wp_encode_emoji($content) { |
|
| 4426 | + if (function_exists('mb_convert_encoding')) { |
|
| 4428 | 4427 | $regex = '/( |
| 4429 | 4428 | \x23\xE2\x83\xA3 # Digits |
| 4430 | 4429 | [\x30-\x39]\xE2\x83\xA3 |
@@ -4436,18 +4435,18 @@ discard block |
||
| 4436 | 4435 | )/x'; |
| 4437 | 4436 | |
| 4438 | 4437 | $matches = array(); |
| 4439 | - if ( preg_match_all( $regex, $content, $matches ) ) { |
|
| 4440 | - if ( ! empty( $matches[1] ) ) { |
|
| 4441 | - foreach( $matches[1] as $emoji ) { |
|
| 4438 | + if (preg_match_all($regex, $content, $matches)) { |
|
| 4439 | + if ( ! empty($matches[1])) { |
|
| 4440 | + foreach ($matches[1] as $emoji) { |
|
| 4442 | 4441 | /* |
| 4443 | 4442 | * UTF-32's hex encoding is the same as HTML's hex encoding. |
| 4444 | 4443 | * So, by converting the emoji from UTF-8 to UTF-32, we magically |
| 4445 | 4444 | * get the correct hex encoding. |
| 4446 | 4445 | */ |
| 4447 | - $unpacked = unpack( 'H*', mb_convert_encoding( $emoji, 'UTF-32', 'UTF-8' ) ); |
|
| 4448 | - if ( isset( $unpacked[1] ) ) { |
|
| 4449 | - $entity = '&#x' . ltrim( $unpacked[1], '0' ) . ';'; |
|
| 4450 | - $content = str_replace( $emoji, $entity, $content ); |
|
| 4446 | + $unpacked = unpack('H*', mb_convert_encoding($emoji, 'UTF-32', 'UTF-8')); |
|
| 4447 | + if (isset($unpacked[1])) { |
|
| 4448 | + $entity = '&#x'.ltrim($unpacked[1], '0').';'; |
|
| 4449 | + $content = str_replace($emoji, $entity, $content); |
|
| 4451 | 4450 | } |
| 4452 | 4451 | } |
| 4453 | 4452 | } |
@@ -4465,14 +4464,14 @@ discard block |
||
| 4465 | 4464 | * @param string $text The content to encode. |
| 4466 | 4465 | * @return string The encoded content. |
| 4467 | 4466 | */ |
| 4468 | -function wp_staticize_emoji( $text ) { |
|
| 4469 | - $text = wp_encode_emoji( $text ); |
|
| 4467 | +function wp_staticize_emoji($text) { |
|
| 4468 | + $text = wp_encode_emoji($text); |
|
| 4470 | 4469 | |
| 4471 | 4470 | /** This filter is documented in wp-includes/formatting.php */ |
| 4472 | - $cdn_url = apply_filters( 'emoji_url', set_url_scheme( '//s.w.org/images/core/emoji/72x72/' ) ); |
|
| 4471 | + $cdn_url = apply_filters('emoji_url', set_url_scheme('//s.w.org/images/core/emoji/72x72/')); |
|
| 4473 | 4472 | |
| 4474 | 4473 | /** This filter is documented in wp-includes/formatting.php */ |
| 4475 | - $ext = apply_filters( 'emoji_ext', '.png' ); |
|
| 4474 | + $ext = apply_filters('emoji_ext', '.png'); |
|
| 4476 | 4475 | |
| 4477 | 4476 | $output = ''; |
| 4478 | 4477 | /* |
@@ -4481,33 +4480,33 @@ discard block |
||
| 4481 | 4480 | * |
| 4482 | 4481 | * First, capture the tags as well as in between. |
| 4483 | 4482 | */ |
| 4484 | - $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); |
|
| 4485 | - $stop = count( $textarr ); |
|
| 4483 | + $textarr = preg_split('/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 4484 | + $stop = count($textarr); |
|
| 4486 | 4485 | |
| 4487 | 4486 | // Ignore processing of specific tags. |
| 4488 | 4487 | $tags_to_ignore = 'code|pre|style|script|textarea'; |
| 4489 | 4488 | $ignore_block_element = ''; |
| 4490 | 4489 | |
| 4491 | - for ( $i = 0; $i < $stop; $i++ ) { |
|
| 4490 | + for ($i = 0; $i < $stop; $i++) { |
|
| 4492 | 4491 | $content = $textarr[$i]; |
| 4493 | 4492 | |
| 4494 | 4493 | // If we're in an ignore block, wait until we find its closing tag. |
| 4495 | - if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { |
|
| 4494 | + if ('' == $ignore_block_element && preg_match('/^<('.$tags_to_ignore.')>/', $content, $matches)) { |
|
| 4496 | 4495 | $ignore_block_element = $matches[1]; |
| 4497 | 4496 | } |
| 4498 | 4497 | |
| 4499 | 4498 | // If it's not a tag and not in ignore block. |
| 4500 | - if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { |
|
| 4499 | + if ('' == $ignore_block_element && strlen($content) > 0 && '<' != $content[0]) { |
|
| 4501 | 4500 | $matches = array(); |
| 4502 | - if ( preg_match_all( '/(DZ(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches ) ) { |
|
| 4503 | - if ( ! empty( $matches[0] ) ) { |
|
| 4504 | - foreach ( $matches[0] as $flag ) { |
|
| 4505 | - $chars = str_replace( array( '&#x', ';'), '', $flag ); |
|
| 4501 | + if (preg_match_all('/(DZ(e[6-9a-f]|f[0-9a-f]);){2}/', $content, $matches)) { |
|
| 4502 | + if ( ! empty($matches[0])) { |
|
| 4503 | + foreach ($matches[0] as $flag) { |
|
| 4504 | + $chars = str_replace(array('&#x', ';'), '', $flag); |
|
| 4506 | 4505 | |
| 4507 | - list( $char1, $char2 ) = str_split( $chars, 5 ); |
|
| 4508 | - $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char1 . '-' . $char2 . $ext, html_entity_decode( $flag ) ); |
|
| 4506 | + list($char1, $char2) = str_split($chars, 5); |
|
| 4507 | + $entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url.$char1.'-'.$char2.$ext, html_entity_decode($flag)); |
|
| 4509 | 4508 | |
| 4510 | - $content = str_replace( $flag, $entity, $content ); |
|
| 4509 | + $content = str_replace($flag, $entity, $content); |
|
| 4511 | 4510 | } |
| 4512 | 4511 | } |
| 4513 | 4512 | } |
@@ -4516,20 +4515,20 @@ discard block |
||
| 4516 | 4515 | $regex = '/(&#x[2-3][0-9a-f]{3};|[1-6][0-9a-f]{2};)/'; |
| 4517 | 4516 | |
| 4518 | 4517 | $matches = array(); |
| 4519 | - if ( preg_match_all( $regex, $content, $matches ) ) { |
|
| 4520 | - if ( ! empty( $matches[1] ) ) { |
|
| 4521 | - foreach ( $matches[1] as $emoji ) { |
|
| 4522 | - $char = str_replace( array( '&#x', ';'), '', $emoji ); |
|
| 4523 | - $entity = sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url . $char . $ext, html_entity_decode( $emoji ) ); |
|
| 4518 | + if (preg_match_all($regex, $content, $matches)) { |
|
| 4519 | + if ( ! empty($matches[1])) { |
|
| 4520 | + foreach ($matches[1] as $emoji) { |
|
| 4521 | + $char = str_replace(array('&#x', ';'), '', $emoji); |
|
| 4522 | + $entity = sprintf('<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', $cdn_url.$char.$ext, html_entity_decode($emoji)); |
|
| 4524 | 4523 | |
| 4525 | - $content = str_replace( $emoji, $entity, $content ); |
|
| 4524 | + $content = str_replace($emoji, $entity, $content); |
|
| 4526 | 4525 | } |
| 4527 | 4526 | } |
| 4528 | 4527 | } |
| 4529 | 4528 | } |
| 4530 | 4529 | |
| 4531 | 4530 | // Did we exit ignore block. |
| 4532 | - if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { |
|
| 4531 | + if ('' != $ignore_block_element && '</'.$ignore_block_element.'>' == $content) { |
|
| 4533 | 4532 | $ignore_block_element = ''; |
| 4534 | 4533 | } |
| 4535 | 4534 | |
@@ -4547,8 +4546,8 @@ discard block |
||
| 4547 | 4546 | * @param array $mail The email data array. |
| 4548 | 4547 | * @return array The email data array, with emoji in the message staticized. |
| 4549 | 4548 | */ |
| 4550 | -function wp_staticize_emoji_for_email( $mail ) { |
|
| 4551 | - if ( ! isset( $mail['message'] ) ) { |
|
| 4549 | +function wp_staticize_emoji_for_email($mail) { |
|
| 4550 | + if ( ! isset($mail['message'])) { |
|
| 4552 | 4551 | return $mail; |
| 4553 | 4552 | } |
| 4554 | 4553 | |
@@ -4560,47 +4559,47 @@ discard block |
||
| 4560 | 4559 | * is handling changing the Content-Type. |
| 4561 | 4560 | */ |
| 4562 | 4561 | $headers = array(); |
| 4563 | - if ( isset( $mail['headers'] ) ) { |
|
| 4564 | - if ( is_array( $mail['headers'] ) ) { |
|
| 4562 | + if (isset($mail['headers'])) { |
|
| 4563 | + if (is_array($mail['headers'])) { |
|
| 4565 | 4564 | $headers = $mail['headers']; |
| 4566 | 4565 | } else { |
| 4567 | - $headers = explode( "\n", str_replace( "\r\n", "\n", $mail['headers'] ) ); |
|
| 4566 | + $headers = explode("\n", str_replace("\r\n", "\n", $mail['headers'])); |
|
| 4568 | 4567 | } |
| 4569 | 4568 | } |
| 4570 | 4569 | |
| 4571 | - foreach ( $headers as $header ) { |
|
| 4572 | - if ( strpos($header, ':') === false ) { |
|
| 4570 | + foreach ($headers as $header) { |
|
| 4571 | + if (strpos($header, ':') === false) { |
|
| 4573 | 4572 | continue; |
| 4574 | 4573 | } |
| 4575 | 4574 | |
| 4576 | 4575 | // Explode them out. |
| 4577 | - list( $name, $content ) = explode( ':', trim( $header ), 2 ); |
|
| 4576 | + list($name, $content) = explode(':', trim($header), 2); |
|
| 4578 | 4577 | |
| 4579 | 4578 | // Cleanup crew. |
| 4580 | - $name = trim( $name ); |
|
| 4581 | - $content = trim( $content ); |
|
| 4579 | + $name = trim($name); |
|
| 4580 | + $content = trim($content); |
|
| 4582 | 4581 | |
| 4583 | - if ( 'content-type' === strtolower( $name ) ) { |
|
| 4584 | - if ( strpos( $content, ';' ) !== false ) { |
|
| 4585 | - list( $type, $charset ) = explode( ';', $content ); |
|
| 4586 | - $content_type = trim( $type ); |
|
| 4582 | + if ('content-type' === strtolower($name)) { |
|
| 4583 | + if (strpos($content, ';') !== false) { |
|
| 4584 | + list($type, $charset) = explode(';', $content); |
|
| 4585 | + $content_type = trim($type); |
|
| 4587 | 4586 | } else { |
| 4588 | - $content_type = trim( $content ); |
|
| 4587 | + $content_type = trim($content); |
|
| 4589 | 4588 | } |
| 4590 | 4589 | break; |
| 4591 | 4590 | } |
| 4592 | 4591 | } |
| 4593 | 4592 | |
| 4594 | 4593 | // Set Content-Type if we don't have a content-type from the input headers. |
| 4595 | - if ( ! isset( $content_type ) ) { |
|
| 4594 | + if ( ! isset($content_type)) { |
|
| 4596 | 4595 | $content_type = 'text/plain'; |
| 4597 | 4596 | } |
| 4598 | 4597 | |
| 4599 | 4598 | /** This filter is documented in wp-includes/pluggable.php */ |
| 4600 | - $content_type = apply_filters( 'wp_mail_content_type', $content_type ); |
|
| 4599 | + $content_type = apply_filters('wp_mail_content_type', $content_type); |
|
| 4601 | 4600 | |
| 4602 | - if ( 'text/html' === $content_type ) { |
|
| 4603 | - $mail['message'] = wp_staticize_emoji( $mail['message'] ); |
|
| 4601 | + if ('text/html' === $content_type) { |
|
| 4602 | + $mail['message'] = wp_staticize_emoji($mail['message']); |
|
| 4604 | 4603 | } |
| 4605 | 4604 | |
| 4606 | 4605 | return $mail; |
@@ -456,8 +456,9 @@ discard block |
||
| 456 | 456 | function wpautop( $pee, $br = true ) { |
| 457 | 457 | $pre_tags = array(); |
| 458 | 458 | |
| 459 | - if ( trim($pee) === '' ) |
|
| 460 | - return ''; |
|
| 459 | + if ( trim($pee) === '' ) { |
|
| 460 | + return ''; |
|
| 461 | + } |
|
| 461 | 462 | |
| 462 | 463 | // Just to make things a little easier, pad the end. |
| 463 | 464 | $pee = $pee . "\n"; |
@@ -592,8 +593,9 @@ discard block |
||
| 592 | 593 | $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); |
| 593 | 594 | |
| 594 | 595 | // Replace placeholder <pre> tags with their original content. |
| 595 | - if ( !empty($pre_tags) ) |
|
| 596 | - $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); |
|
| 596 | + if ( !empty($pre_tags) ) { |
|
| 597 | + $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); |
|
| 598 | + } |
|
| 597 | 599 | |
| 598 | 600 | // Restore newlines in all elements. |
| 599 | 601 | $pee = str_replace( " <!-- wpnl --> ", "\n", $pee ); |
@@ -786,16 +788,38 @@ discard block |
||
| 786 | 788 | reset_mbstring_encoding(); |
| 787 | 789 | for ($i=0; $i < $length; $i++) { |
| 788 | 790 | $c = ord($str[$i]); |
| 789 | - if ($c < 0x80) $n = 0; // 0bbbbbbb |
|
| 790 | - elseif (($c & 0xE0) == 0xC0) $n=1; // 110bbbbb |
|
| 791 | - elseif (($c & 0xF0) == 0xE0) $n=2; // 1110bbbb |
|
| 792 | - elseif (($c & 0xF8) == 0xF0) $n=3; // 11110bbb |
|
| 793 | - elseif (($c & 0xFC) == 0xF8) $n=4; // 111110bb |
|
| 794 | - elseif (($c & 0xFE) == 0xFC) $n=5; // 1111110b |
|
| 795 | - else return false; // Does not match any model |
|
| 791 | + if ($c < 0x80) { |
|
| 792 | + $n = 0; |
|
| 793 | + } |
|
| 794 | + // 0bbbbbbb |
|
| 795 | + elseif (($c & 0xE0) == 0xC0) { |
|
| 796 | + $n=1; |
|
| 797 | + } |
|
| 798 | + // 110bbbbb |
|
| 799 | + elseif (($c & 0xF0) == 0xE0) { |
|
| 800 | + $n=2; |
|
| 801 | + } |
|
| 802 | + // 1110bbbb |
|
| 803 | + elseif (($c & 0xF8) == 0xF0) { |
|
| 804 | + $n=3; |
|
| 805 | + } |
|
| 806 | + // 11110bbb |
|
| 807 | + elseif (($c & 0xFC) == 0xF8) { |
|
| 808 | + $n=4; |
|
| 809 | + } |
|
| 810 | + // 111110bb |
|
| 811 | + elseif (($c & 0xFE) == 0xFC) { |
|
| 812 | + $n=5; |
|
| 813 | + } |
|
| 814 | + // 1111110b |
|
| 815 | + else { |
|
| 816 | + return false; |
|
| 817 | + } |
|
| 818 | + // Does not match any model |
|
| 796 | 819 | for ($j=0; $j<$n; $j++) { // n bytes matching 10bbbbbb follow ? |
| 797 | - if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
| 798 | - return false; |
|
| 820 | + if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
| 821 | + return false; |
|
| 822 | + } |
|
| 799 | 823 | } |
| 800 | 824 | } |
| 801 | 825 | return true; |
@@ -823,18 +847,21 @@ discard block |
||
| 823 | 847 | function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { |
| 824 | 848 | $string = (string) $string; |
| 825 | 849 | |
| 826 | - if ( 0 === strlen( $string ) ) |
|
| 827 | - return ''; |
|
| 850 | + if ( 0 === strlen( $string ) ) { |
|
| 851 | + return ''; |
|
| 852 | + } |
|
| 828 | 853 | |
| 829 | 854 | // Don't bother if there are no specialchars - saves some processing |
| 830 | - if ( ! preg_match( '/[&<>"\']/', $string ) ) |
|
| 831 | - return $string; |
|
| 855 | + if ( ! preg_match( '/[&<>"\']/', $string ) ) { |
|
| 856 | + return $string; |
|
| 857 | + } |
|
| 832 | 858 | |
| 833 | 859 | // Account for the previous behaviour of the function when the $quote_style is not an accepted value |
| 834 | - if ( empty( $quote_style ) ) |
|
| 835 | - $quote_style = ENT_NOQUOTES; |
|
| 836 | - elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) |
|
| 837 | - $quote_style = ENT_QUOTES; |
|
| 860 | + if ( empty( $quote_style ) ) { |
|
| 861 | + $quote_style = ENT_NOQUOTES; |
|
| 862 | + } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { |
|
| 863 | + $quote_style = ENT_QUOTES; |
|
| 864 | + } |
|
| 838 | 865 | |
| 839 | 866 | // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() |
| 840 | 867 | if ( ! $charset ) { |
@@ -846,8 +873,9 @@ discard block |
||
| 846 | 873 | $charset = $_charset; |
| 847 | 874 | } |
| 848 | 875 | |
| 849 | - if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) |
|
| 850 | - $charset = 'UTF-8'; |
|
| 876 | + if ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) ) { |
|
| 877 | + $charset = 'UTF-8'; |
|
| 878 | + } |
|
| 851 | 879 | |
| 852 | 880 | $_quote_style = $quote_style; |
| 853 | 881 | |
@@ -867,8 +895,9 @@ discard block |
||
| 867 | 895 | $string = @htmlspecialchars( $string, $quote_style, $charset, $double_encode ); |
| 868 | 896 | |
| 869 | 897 | // Backwards compatibility |
| 870 | - if ( 'single' === $_quote_style ) |
|
| 871 | - $string = str_replace( "'", ''', $string ); |
|
| 898 | + if ( 'single' === $_quote_style ) { |
|
| 899 | + $string = str_replace( "'", ''', $string ); |
|
| 900 | + } |
|
| 872 | 901 | |
| 873 | 902 | return $string; |
| 874 | 903 | } |
@@ -1016,8 +1045,9 @@ discard block |
||
| 1016 | 1045 | $value = ord( $utf8_string[ $i ] ); |
| 1017 | 1046 | |
| 1018 | 1047 | if ( $value < 128 ) { |
| 1019 | - if ( $length && ( $unicode_length >= $length ) ) |
|
| 1020 | - break; |
|
| 1048 | + if ( $length && ( $unicode_length >= $length ) ) { |
|
| 1049 | + break; |
|
| 1050 | + } |
|
| 1021 | 1051 | $unicode .= chr($value); |
| 1022 | 1052 | $unicode_length++; |
| 1023 | 1053 | } else { |
@@ -1033,8 +1063,9 @@ discard block |
||
| 1033 | 1063 | |
| 1034 | 1064 | $values[] = $value; |
| 1035 | 1065 | |
| 1036 | - if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) |
|
| 1037 | - break; |
|
| 1066 | + if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) { |
|
| 1067 | + break; |
|
| 1068 | + } |
|
| 1038 | 1069 | if ( count( $values ) == $num_octets ) { |
| 1039 | 1070 | for ( $j = 0; $j < $num_octets; $j++ ) { |
| 1040 | 1071 | $unicode .= '%' . dechex( $values[ $j ] ); |
@@ -1062,8 +1093,9 @@ discard block |
||
| 1062 | 1093 | * @return string Filtered string with replaced "nice" characters. |
| 1063 | 1094 | */ |
| 1064 | 1095 | function remove_accents( $string ) { |
| 1065 | - if ( !preg_match('/[\x80-\xff]/', $string) ) |
|
| 1066 | - return $string; |
|
| 1096 | + if ( !preg_match('/[\x80-\xff]/', $string) ) { |
|
| 1097 | + return $string; |
|
| 1098 | + } |
|
| 1067 | 1099 | |
| 1068 | 1100 | if (seems_utf8($string)) { |
| 1069 | 1101 | $chars = array( |
@@ -1358,8 +1390,9 @@ discard block |
||
| 1358 | 1390 | break; |
| 1359 | 1391 | } |
| 1360 | 1392 | } |
| 1361 | - if ( !$allowed ) |
|
| 1362 | - $filename .= '_'; |
|
| 1393 | + if ( !$allowed ) { |
|
| 1394 | + $filename .= '_'; |
|
| 1395 | + } |
|
| 1363 | 1396 | } |
| 1364 | 1397 | } |
| 1365 | 1398 | $filename .= '.' . $extension; |
@@ -1390,8 +1423,9 @@ discard block |
||
| 1390 | 1423 | $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities |
| 1391 | 1424 | |
| 1392 | 1425 | // If strict, reduce to ASCII for max portability. |
| 1393 | - if ( $strict ) |
|
| 1394 | - $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); |
|
| 1426 | + if ( $strict ) { |
|
| 1427 | + $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); |
|
| 1428 | + } |
|
| 1395 | 1429 | |
| 1396 | 1430 | $username = trim( $username ); |
| 1397 | 1431 | // Consolidate contiguous whitespace |
@@ -1452,8 +1486,9 @@ discard block |
||
| 1452 | 1486 | function sanitize_title( $title, $fallback_title = '', $context = 'save' ) { |
| 1453 | 1487 | $raw_title = $title; |
| 1454 | 1488 | |
| 1455 | - if ( 'save' == $context ) |
|
| 1456 | - $title = remove_accents($title); |
|
| 1489 | + if ( 'save' == $context ) { |
|
| 1490 | + $title = remove_accents($title); |
|
| 1491 | + } |
|
| 1457 | 1492 | |
| 1458 | 1493 | /** |
| 1459 | 1494 | * Filter a sanitized title string. |
@@ -1466,8 +1501,9 @@ discard block |
||
| 1466 | 1501 | */ |
| 1467 | 1502 | $title = apply_filters( 'sanitize_title', $title, $raw_title, $context ); |
| 1468 | 1503 | |
| 1469 | - if ( '' === $title || false === $title ) |
|
| 1470 | - $title = $fallback_title; |
|
| 1504 | + if ( '' === $title || false === $title ) { |
|
| 1505 | + $title = $fallback_title; |
|
| 1506 | + } |
|
| 1471 | 1507 | |
| 1472 | 1508 | return $title; |
| 1473 | 1509 | } |
@@ -1594,8 +1630,9 @@ discard block |
||
| 1594 | 1630 | //Limit to A-Z,a-z,0-9,_,- |
| 1595 | 1631 | $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); |
| 1596 | 1632 | |
| 1597 | - if ( '' == $sanitized ) |
|
| 1598 | - $sanitized = $fallback; |
|
| 1633 | + if ( '' == $sanitized ) { |
|
| 1634 | + $sanitized = $fallback; |
|
| 1635 | + } |
|
| 1599 | 1636 | |
| 1600 | 1637 | /** |
| 1601 | 1638 | * Filter a sanitized HTML class string. |
@@ -1779,8 +1816,9 @@ discard block |
||
| 1779 | 1816 | elseif ( substr( $regex[2], -1 ) == '/' ) { |
| 1780 | 1817 | // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and |
| 1781 | 1818 | // immediately close it with a closing tag (the tag will encapsulate no text as a result) |
| 1782 | - if ( ! in_array( $tag, $single_tags ) ) |
|
| 1783 | - $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; |
|
| 1819 | + if ( ! in_array( $tag, $single_tags ) ) { |
|
| 1820 | + $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; |
|
| 1821 | + } |
|
| 1784 | 1822 | } |
| 1785 | 1823 | // ElseIf it's a known single-entity tag but it doesn't close itself, do so |
| 1786 | 1824 | elseif ( in_array($tag, $single_tags) ) { |
@@ -1798,8 +1836,9 @@ discard block |
||
| 1798 | 1836 | |
| 1799 | 1837 | // Attributes |
| 1800 | 1838 | $attributes = $regex[2]; |
| 1801 | - if ( ! empty( $attributes ) && $attributes[0] != '>' ) |
|
| 1802 | - $attributes = ' ' . $attributes; |
|
| 1839 | + if ( ! empty( $attributes ) && $attributes[0] != '>' ) { |
|
| 1840 | + $attributes = ' ' . $attributes; |
|
| 1841 | + } |
|
| 1803 | 1842 | |
| 1804 | 1843 | $tag = '<' . $tag . $attributes . '>'; |
| 1805 | 1844 | //If already queuing a close tag, then put this tag on, too |
@@ -1819,8 +1858,10 @@ discard block |
||
| 1819 | 1858 | $newtext .= $text; |
| 1820 | 1859 | |
| 1821 | 1860 | // Empty Stack |
| 1822 | - while( $x = array_pop($tagstack) ) |
|
| 1823 | - $newtext .= '</' . $x . '>'; // Add remaining tags to close |
|
| 1861 | + while( $x = array_pop($tagstack) ) { |
|
| 1862 | + $newtext .= '</' . $x . '>'; |
|
| 1863 | + } |
|
| 1864 | + // Add remaining tags to close |
|
| 1824 | 1865 | |
| 1825 | 1866 | // WP fix for the bug with HTML comments |
| 1826 | 1867 | $newtext = str_replace("< !--","<!--",$newtext); |
@@ -1851,8 +1892,9 @@ discard block |
||
| 1851 | 1892 | * @param string $content The text, prior to formatting for editing. |
| 1852 | 1893 | */ |
| 1853 | 1894 | $content = apply_filters( 'format_to_edit', $content ); |
| 1854 | - if ( ! $richedit ) |
|
| 1855 | - $content = esc_textarea( $content ); |
|
| 1895 | + if ( ! $richedit ) { |
|
| 1896 | + $content = esc_textarea( $content ); |
|
| 1897 | + } |
|
| 1856 | 1898 | return $content; |
| 1857 | 1899 | } |
| 1858 | 1900 | |
@@ -1886,8 +1928,9 @@ discard block |
||
| 1886 | 1928 | * @return string String with backslashes inserted. |
| 1887 | 1929 | */ |
| 1888 | 1930 | function backslashit( $string ) { |
| 1889 | - if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) |
|
| 1890 | - $string = '\\\\' . $string; |
|
| 1931 | + if ( isset( $string[0] ) && $string[0] >= '0' && $string[0] <= '9' ) { |
|
| 1932 | + $string = '\\\\' . $string; |
|
| 1933 | + } |
|
| 1891 | 1934 | return addcslashes( $string, 'A..Za..z' ); |
| 1892 | 1935 | } |
| 1893 | 1936 | |
@@ -1936,8 +1979,9 @@ discard block |
||
| 1936 | 1979 | * @return string Returns a string escaped with slashes. |
| 1937 | 1980 | */ |
| 1938 | 1981 | function addslashes_gpc($gpc) { |
| 1939 | - if ( get_magic_quotes_gpc() ) |
|
| 1940 | - $gpc = stripslashes($gpc); |
|
| 1982 | + if ( get_magic_quotes_gpc() ) { |
|
| 1983 | + $gpc = stripslashes($gpc); |
|
| 1984 | + } |
|
| 1941 | 1985 | |
| 1942 | 1986 | return wp_slash($gpc); |
| 1943 | 1987 | } |
@@ -2049,8 +2093,9 @@ discard block |
||
| 2049 | 2093 | } |
| 2050 | 2094 | |
| 2051 | 2095 | $url = esc_url($url); |
| 2052 | - if ( empty($url) ) |
|
| 2053 | - return $matches[0]; |
|
| 2096 | + if ( empty($url) ) { |
|
| 2097 | + return $matches[0]; |
|
| 2098 | + } |
|
| 2054 | 2099 | |
| 2055 | 2100 | return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; |
| 2056 | 2101 | } |
@@ -2072,8 +2117,9 @@ discard block |
||
| 2072 | 2117 | $dest = $matches[2]; |
| 2073 | 2118 | $dest = 'http://' . $dest; |
| 2074 | 2119 | $dest = esc_url($dest); |
| 2075 | - if ( empty($dest) ) |
|
| 2076 | - return $matches[0]; |
|
| 2120 | + if ( empty($dest) ) { |
|
| 2121 | + return $matches[0]; |
|
| 2122 | + } |
|
| 2077 | 2123 | |
| 2078 | 2124 | // removed trailing [.,;:)] from URL |
| 2079 | 2125 | if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) { |
@@ -2117,10 +2163,11 @@ discard block |
||
| 2117 | 2163 | $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> |
| 2118 | 2164 | foreach ( $textarr as $piece ) { |
| 2119 | 2165 | |
| 2120 | - if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) |
|
| 2121 | - $nested_code_pre++; |
|
| 2122 | - elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) |
|
| 2123 | - $nested_code_pre--; |
|
| 2166 | + if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) ) { |
|
| 2167 | + $nested_code_pre++; |
|
| 2168 | + } elseif ( ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) ) && $nested_code_pre ) { |
|
| 2169 | + $nested_code_pre--; |
|
| 2170 | + } |
|
| 2124 | 2171 | |
| 2125 | 2172 | if ( $nested_code_pre || empty( $piece ) || ( $piece[0] === '<' && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) { |
| 2126 | 2173 | $r .= $piece; |
@@ -2274,8 +2321,9 @@ discard block |
||
| 2274 | 2321 | function translate_smiley( $matches ) { |
| 2275 | 2322 | global $wpsmiliestrans; |
| 2276 | 2323 | |
| 2277 | - if ( count( $matches ) == 0 ) |
|
| 2278 | - return ''; |
|
| 2324 | + if ( count( $matches ) == 0 ) { |
|
| 2325 | + return ''; |
|
| 2326 | + } |
|
| 2279 | 2327 | |
| 2280 | 2328 | $smiley = trim( reset( $matches ) ); |
| 2281 | 2329 | $img = $wpsmiliestrans[ $smiley ]; |
@@ -2367,8 +2415,9 @@ discard block |
||
| 2367 | 2415 | * @return string|bool Either false or the valid email address. |
| 2368 | 2416 | */ |
| 2369 | 2417 | function is_email( $email, $deprecated = false ) { |
| 2370 | - if ( ! empty( $deprecated ) ) |
|
| 2371 | - _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 2418 | + if ( ! empty( $deprecated ) ) { |
|
| 2419 | + _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 2420 | + } |
|
| 2372 | 2421 | |
| 2373 | 2422 | // Test for the minimum length the email can be |
| 2374 | 2423 | if ( strlen( $email ) < 3 ) { |
@@ -2496,13 +2545,15 @@ discard block |
||
| 2496 | 2545 | $tz = get_option( 'timezone_string' ); |
| 2497 | 2546 | if ( $tz ) { |
| 2498 | 2547 | $datetime = date_create( $string, new DateTimeZone( $tz ) ); |
| 2499 | - if ( ! $datetime ) |
|
| 2500 | - return gmdate( $format, 0 ); |
|
| 2548 | + if ( ! $datetime ) { |
|
| 2549 | + return gmdate( $format, 0 ); |
|
| 2550 | + } |
|
| 2501 | 2551 | $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); |
| 2502 | 2552 | $string_gmt = $datetime->format( $format ); |
| 2503 | 2553 | } else { |
| 2504 | - if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) |
|
| 2505 | - return gmdate( $format, 0 ); |
|
| 2554 | + if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) { |
|
| 2555 | + return gmdate( $format, 0 ); |
|
| 2556 | + } |
|
| 2506 | 2557 | $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
| 2507 | 2558 | $string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
| 2508 | 2559 | } |
@@ -2527,13 +2578,15 @@ discard block |
||
| 2527 | 2578 | $tz = get_option( 'timezone_string' ); |
| 2528 | 2579 | if ( $tz ) { |
| 2529 | 2580 | $datetime = date_create( $string, new DateTimeZone( 'UTC' ) ); |
| 2530 | - if ( ! $datetime ) |
|
| 2531 | - return date( $format, 0 ); |
|
| 2581 | + if ( ! $datetime ) { |
|
| 2582 | + return date( $format, 0 ); |
|
| 2583 | + } |
|
| 2532 | 2584 | $datetime->setTimezone( new DateTimeZone( $tz ) ); |
| 2533 | 2585 | $string_localtime = $datetime->format( $format ); |
| 2534 | 2586 | } else { |
| 2535 | - if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) ) |
|
| 2536 | - return date( $format, 0 ); |
|
| 2587 | + if ( ! preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches) ) { |
|
| 2588 | + return date( $format, 0 ); |
|
| 2589 | + } |
|
| 2537 | 2590 | $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); |
| 2538 | 2591 | $string_localtime = gmdate( $format, $string_time + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
| 2539 | 2592 | } |
@@ -2733,34 +2786,40 @@ discard block |
||
| 2733 | 2786 | |
| 2734 | 2787 | if ( $diff < HOUR_IN_SECONDS ) { |
| 2735 | 2788 | $mins = round( $diff / MINUTE_IN_SECONDS ); |
| 2736 | - if ( $mins <= 1 ) |
|
| 2737 | - $mins = 1; |
|
| 2789 | + if ( $mins <= 1 ) { |
|
| 2790 | + $mins = 1; |
|
| 2791 | + } |
|
| 2738 | 2792 | /* translators: min=minute */ |
| 2739 | 2793 | $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); |
| 2740 | 2794 | } elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { |
| 2741 | 2795 | $hours = round( $diff / HOUR_IN_SECONDS ); |
| 2742 | - if ( $hours <= 1 ) |
|
| 2743 | - $hours = 1; |
|
| 2796 | + if ( $hours <= 1 ) { |
|
| 2797 | + $hours = 1; |
|
| 2798 | + } |
|
| 2744 | 2799 | $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); |
| 2745 | 2800 | } elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) { |
| 2746 | 2801 | $days = round( $diff / DAY_IN_SECONDS ); |
| 2747 | - if ( $days <= 1 ) |
|
| 2748 | - $days = 1; |
|
| 2802 | + if ( $days <= 1 ) { |
|
| 2803 | + $days = 1; |
|
| 2804 | + } |
|
| 2749 | 2805 | $since = sprintf( _n( '%s day', '%s days', $days ), $days ); |
| 2750 | 2806 | } elseif ( $diff < 30 * DAY_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) { |
| 2751 | 2807 | $weeks = round( $diff / WEEK_IN_SECONDS ); |
| 2752 | - if ( $weeks <= 1 ) |
|
| 2753 | - $weeks = 1; |
|
| 2808 | + if ( $weeks <= 1 ) { |
|
| 2809 | + $weeks = 1; |
|
| 2810 | + } |
|
| 2754 | 2811 | $since = sprintf( _n( '%s week', '%s weeks', $weeks ), $weeks ); |
| 2755 | 2812 | } elseif ( $diff < YEAR_IN_SECONDS && $diff >= 30 * DAY_IN_SECONDS ) { |
| 2756 | 2813 | $months = round( $diff / ( 30 * DAY_IN_SECONDS ) ); |
| 2757 | - if ( $months <= 1 ) |
|
| 2758 | - $months = 1; |
|
| 2814 | + if ( $months <= 1 ) { |
|
| 2815 | + $months = 1; |
|
| 2816 | + } |
|
| 2759 | 2817 | $since = sprintf( _n( '%s month', '%s months', $months ), $months ); |
| 2760 | 2818 | } elseif ( $diff >= YEAR_IN_SECONDS ) { |
| 2761 | 2819 | $years = round( $diff / YEAR_IN_SECONDS ); |
| 2762 | - if ( $years <= 1 ) |
|
| 2763 | - $years = 1; |
|
| 2820 | + if ( $years <= 1 ) { |
|
| 2821 | + $years = 1; |
|
| 2822 | + } |
|
| 2764 | 2823 | $since = sprintf( _n( '%s year', '%s years', $years ), $years ); |
| 2765 | 2824 | } |
| 2766 | 2825 | |
@@ -2911,8 +2970,9 @@ discard block |
||
| 2911 | 2970 | * @param string $text The text prior to entity conversion. |
| 2912 | 2971 | */ |
| 2913 | 2972 | $filtered = apply_filters( 'pre_ent2ncr', null, $text ); |
| 2914 | - if ( null !== $filtered ) |
|
| 2915 | - return $filtered; |
|
| 2973 | + if ( null !== $filtered ) { |
|
| 2974 | + return $filtered; |
|
| 2975 | + } |
|
| 2916 | 2976 | |
| 2917 | 2977 | $to_ncr = array( |
| 2918 | 2978 | '"' => '"', |
@@ -3268,8 +3328,9 @@ discard block |
||
| 3268 | 3328 | function esc_url( $url, $protocols = null, $_context = 'display' ) { |
| 3269 | 3329 | $original_url = $url; |
| 3270 | 3330 | |
| 3271 | - if ( '' == $url ) |
|
| 3272 | - return $url; |
|
| 3331 | + if ( '' == $url ) { |
|
| 3332 | + return $url; |
|
| 3333 | + } |
|
| 3273 | 3334 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); |
| 3274 | 3335 | if ( 0 !== stripos( $url, 'mailto:' ) ) { |
| 3275 | 3336 | $strip = array('%0d', '%0a', '%0D', '%0A'); |
@@ -3281,8 +3342,9 @@ discard block |
||
| 3281 | 3342 | * link starting with /, # or ? or a php file). |
| 3282 | 3343 | */ |
| 3283 | 3344 | if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && |
| 3284 | - ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) |
|
| 3285 | - $url = 'http://' . $url; |
|
| 3345 | + ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) { |
|
| 3346 | + $url = 'http://' . $url; |
|
| 3347 | + } |
|
| 3286 | 3348 | |
| 3287 | 3349 | // Replace ampersands and single quotes only when displaying. |
| 3288 | 3350 | if ( 'display' == $_context ) { |
@@ -3294,11 +3356,13 @@ discard block |
||
| 3294 | 3356 | if ( '/' === $url[0] ) { |
| 3295 | 3357 | $good_protocol_url = $url; |
| 3296 | 3358 | } else { |
| 3297 | - if ( ! is_array( $protocols ) ) |
|
| 3298 | - $protocols = wp_allowed_protocols(); |
|
| 3359 | + if ( ! is_array( $protocols ) ) { |
|
| 3360 | + $protocols = wp_allowed_protocols(); |
|
| 3361 | + } |
|
| 3299 | 3362 | $good_protocol_url = wp_kses_bad_protocol( $url, $protocols ); |
| 3300 | - if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) |
|
| 3301 | - return ''; |
|
| 3363 | + if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) { |
|
| 3364 | + return ''; |
|
| 3365 | + } |
|
| 3302 | 3366 | } |
| 3303 | 3367 | |
| 3304 | 3368 | /** |
@@ -3542,17 +3606,20 @@ discard block |
||
| 3542 | 3606 | case 'posts_per_page': |
| 3543 | 3607 | case 'posts_per_rss': |
| 3544 | 3608 | $value = (int) $value; |
| 3545 | - if ( empty($value) ) |
|
| 3546 | - $value = 1; |
|
| 3547 | - if ( $value < -1 ) |
|
| 3548 | - $value = abs($value); |
|
| 3609 | + if ( empty($value) ) { |
|
| 3610 | + $value = 1; |
|
| 3611 | + } |
|
| 3612 | + if ( $value < -1 ) { |
|
| 3613 | + $value = abs($value); |
|
| 3614 | + } |
|
| 3549 | 3615 | break; |
| 3550 | 3616 | |
| 3551 | 3617 | case 'default_ping_status': |
| 3552 | 3618 | case 'default_comment_status': |
| 3553 | 3619 | // Options that if not there have 0 value but need to be something like "closed" |
| 3554 | - if ( $value == '0' || $value == '') |
|
| 3555 | - $value = 'closed'; |
|
| 3620 | + if ( $value == '0' || $value == '') { |
|
| 3621 | + $value = 'closed'; |
|
| 3622 | + } |
|
| 3556 | 3623 | break; |
| 3557 | 3624 | |
| 3558 | 3625 | case 'blogdescription': |
@@ -3572,10 +3639,11 @@ discard block |
||
| 3572 | 3639 | |
| 3573 | 3640 | case 'blog_public': |
| 3574 | 3641 | // This is the value if the settings checkbox is not checked on POST. Don't rely on this. |
| 3575 | - if ( null === $value ) |
|
| 3576 | - $value = 1; |
|
| 3577 | - else |
|
| 3578 | - $value = intval( $value ); |
|
| 3642 | + if ( null === $value ) { |
|
| 3643 | + $value = 1; |
|
| 3644 | + } else { |
|
| 3645 | + $value = intval( $value ); |
|
| 3646 | + } |
|
| 3579 | 3647 | break; |
| 3580 | 3648 | |
| 3581 | 3649 | case 'date_format': |
@@ -3645,13 +3713,15 @@ discard block |
||
| 3645 | 3713 | if ( is_wp_error( $value ) ) { |
| 3646 | 3714 | $error = $value->get_error_message(); |
| 3647 | 3715 | } else { |
| 3648 | - if ( ! is_array( $value ) ) |
|
| 3649 | - $value = explode( ' ', $value ); |
|
| 3716 | + if ( ! is_array( $value ) ) { |
|
| 3717 | + $value = explode( ' ', $value ); |
|
| 3718 | + } |
|
| 3650 | 3719 | |
| 3651 | 3720 | $value = array_values( array_filter( array_map( 'trim', $value ) ) ); |
| 3652 | 3721 | |
| 3653 | - if ( ! $value ) |
|
| 3654 | - $value = ''; |
|
| 3722 | + if ( ! $value ) { |
|
| 3723 | + $value = ''; |
|
| 3724 | + } |
|
| 3655 | 3725 | } |
| 3656 | 3726 | break; |
| 3657 | 3727 | |
@@ -3661,8 +3731,9 @@ discard block |
||
| 3661 | 3731 | if ( is_wp_error( $value ) ) { |
| 3662 | 3732 | $error = $value->get_error_message(); |
| 3663 | 3733 | } else { |
| 3664 | - if ( ! is_array( $value ) ) |
|
| 3665 | - $value = explode( "\n", $value ); |
|
| 3734 | + if ( ! is_array( $value ) ) { |
|
| 3735 | + $value = explode( "\n", $value ); |
|
| 3736 | + } |
|
| 3666 | 3737 | |
| 3667 | 3738 | $domains = array_values( array_filter( array_map( 'trim', $value ) ) ); |
| 3668 | 3739 | $value = array(); |
@@ -3672,8 +3743,9 @@ discard block |
||
| 3672 | 3743 | $value[] = $domain; |
| 3673 | 3744 | } |
| 3674 | 3745 | } |
| 3675 | - if ( ! $value ) |
|
| 3676 | - $value = ''; |
|
| 3746 | + if ( ! $value ) { |
|
| 3747 | + $value = ''; |
|
| 3748 | + } |
|
| 3677 | 3749 | } |
| 3678 | 3750 | break; |
| 3679 | 3751 | |
@@ -3697,8 +3769,9 @@ discard block |
||
| 3697 | 3769 | break; |
| 3698 | 3770 | |
| 3699 | 3771 | case 'default_role' : |
| 3700 | - if ( ! get_role( $value ) && get_role( 'subscriber' ) ) |
|
| 3701 | - $value = 'subscriber'; |
|
| 3772 | + if ( ! get_role( $value ) && get_role( 'subscriber' ) ) { |
|
| 3773 | + $value = 'subscriber'; |
|
| 3774 | + } |
|
| 3702 | 3775 | break; |
| 3703 | 3776 | |
| 3704 | 3777 | case 'moderation_keys': |
@@ -3748,8 +3821,9 @@ discard block |
||
| 3748 | 3821 | */ |
| 3749 | 3822 | function wp_parse_str( $string, &$array ) { |
| 3750 | 3823 | parse_str( $string, $array ); |
| 3751 | - if ( get_magic_quotes_gpc() ) |
|
| 3752 | - $array = stripslashes_deep( $array ); |
|
| 3824 | + if ( get_magic_quotes_gpc() ) { |
|
| 3825 | + $array = stripslashes_deep( $array ); |
|
| 3826 | + } |
|
| 3753 | 3827 | /** |
| 3754 | 3828 | * Filter the array of variables derived from a parsed string. |
| 3755 | 3829 | * |
@@ -3783,8 +3857,9 @@ discard block |
||
| 3783 | 3857 | * @return string The text returned after esc_html if needed. |
| 3784 | 3858 | */ |
| 3785 | 3859 | function wp_pre_kses_less_than_callback( $matches ) { |
| 3786 | - if ( false === strpos($matches[0], '>') ) |
|
| 3787 | - return esc_html($matches[0]); |
|
| 3860 | + if ( false === strpos($matches[0], '>') ) { |
|
| 3861 | + return esc_html($matches[0]); |
|
| 3862 | + } |
|
| 3788 | 3863 | return $matches[0]; |
| 3789 | 3864 | } |
| 3790 | 3865 | |
@@ -3820,8 +3895,9 @@ discard block |
||
| 3820 | 3895 | |
| 3821 | 3896 | // Get fragment before next % |
| 3822 | 3897 | $end = strpos($pattern, '%', $start + 1); |
| 3823 | - if ( false === $end ) |
|
| 3824 | - $end = $len; |
|
| 3898 | + if ( false === $end ) { |
|
| 3899 | + $end = $len; |
|
| 3900 | + } |
|
| 3825 | 3901 | $fragment = substr($pattern, $start, $end - $start); |
| 3826 | 3902 | |
| 3827 | 3903 | // Fragment has a specifier |
@@ -3846,10 +3922,11 @@ discard block |
||
| 3846 | 3922 | * @param string $arg The argument. |
| 3847 | 3923 | */ |
| 3848 | 3924 | $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); |
| 3849 | - if ( $_fragment != $fragment ) |
|
| 3850 | - $fragment = $_fragment; |
|
| 3851 | - else |
|
| 3852 | - $fragment = sprintf($fragment, strval($arg) ); |
|
| 3925 | + if ( $_fragment != $fragment ) { |
|
| 3926 | + $fragment = $_fragment; |
|
| 3927 | + } else { |
|
| 3928 | + $fragment = sprintf($fragment, strval($arg) ); |
|
| 3929 | + } |
|
| 3853 | 3930 | } |
| 3854 | 3931 | |
| 3855 | 3932 | // Append to result and move to next fragment |
@@ -3874,12 +3951,14 @@ discard block |
||
| 3874 | 3951 | */ |
| 3875 | 3952 | function wp_sprintf_l( $pattern, $args ) { |
| 3876 | 3953 | // Not a match |
| 3877 | - if ( substr($pattern, 0, 2) != '%l' ) |
|
| 3878 | - return $pattern; |
|
| 3954 | + if ( substr($pattern, 0, 2) != '%l' ) { |
|
| 3955 | + return $pattern; |
|
| 3956 | + } |
|
| 3879 | 3957 | |
| 3880 | 3958 | // Nothing to work with |
| 3881 | - if ( empty($args) ) |
|
| 3882 | - return ''; |
|
| 3959 | + if ( empty($args) ) { |
|
| 3960 | + return ''; |
|
| 3961 | + } |
|
| 3883 | 3962 | |
| 3884 | 3963 | /** |
| 3885 | 3964 | * Filter the translated delimiters used by wp_sprintf_l(). |
@@ -3903,17 +3982,19 @@ discard block |
||
| 3903 | 3982 | |
| 3904 | 3983 | $args = (array) $args; |
| 3905 | 3984 | $result = array_shift($args); |
| 3906 | - if ( count($args) == 1 ) |
|
| 3907 | - $result .= $l['between_only_two'] . array_shift($args); |
|
| 3985 | + if ( count($args) == 1 ) { |
|
| 3986 | + $result .= $l['between_only_two'] . array_shift($args); |
|
| 3987 | + } |
|
| 3908 | 3988 | // Loop when more than two args |
| 3909 | 3989 | $i = count($args); |
| 3910 | 3990 | while ( $i ) { |
| 3911 | 3991 | $arg = array_shift($args); |
| 3912 | 3992 | $i--; |
| 3913 | - if ( 0 == $i ) |
|
| 3914 | - $result .= $l['between_last_two'] . $arg; |
|
| 3915 | - else |
|
| 3916 | - $result .= $l['between'] . $arg; |
|
| 3993 | + if ( 0 == $i ) { |
|
| 3994 | + $result .= $l['between_last_two'] . $arg; |
|
| 3995 | + } else { |
|
| 3996 | + $result .= $l['between'] . $arg; |
|
| 3997 | + } |
|
| 3917 | 3998 | } |
| 3918 | 3999 | return $result . substr($pattern, 2); |
| 3919 | 4000 | } |
@@ -3933,14 +4014,16 @@ discard block |
||
| 3933 | 4014 | * @return string The excerpt. |
| 3934 | 4015 | */ |
| 3935 | 4016 | function wp_html_excerpt( $str, $count, $more = null ) { |
| 3936 | - if ( null === $more ) |
|
| 3937 | - $more = ''; |
|
| 4017 | + if ( null === $more ) { |
|
| 4018 | + $more = ''; |
|
| 4019 | + } |
|
| 3938 | 4020 | $str = wp_strip_all_tags( $str, true ); |
| 3939 | 4021 | $excerpt = mb_substr( $str, 0, $count ); |
| 3940 | 4022 | // remove part of an entity at the end |
| 3941 | 4023 | $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); |
| 3942 | - if ( $str != $excerpt ) |
|
| 3943 | - $excerpt = trim( $excerpt ) . $more; |
|
| 4024 | + if ( $str != $excerpt ) { |
|
| 4025 | + $excerpt = trim( $excerpt ) . $more; |
|
| 4026 | + } |
|
| 3944 | 4027 | return $excerpt; |
| 3945 | 4028 | } |
| 3946 | 4029 | |
@@ -4062,8 +4145,9 @@ discard block |
||
| 4062 | 4145 | $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); |
| 4063 | 4146 | $string = strip_tags($string); |
| 4064 | 4147 | |
| 4065 | - if ( $remove_breaks ) |
|
| 4066 | - $string = preg_replace('/[\r\n\t ]+/', ' ', $string); |
|
| 4148 | + if ( $remove_breaks ) { |
|
| 4149 | + $string = preg_replace('/[\r\n\t ]+/', ' ', $string); |
|
| 4150 | + } |
|
| 4067 | 4151 | |
| 4068 | 4152 | return trim( $string ); |
| 4069 | 4153 | } |
@@ -4140,8 +4224,9 @@ discard block |
||
| 4140 | 4224 | function capital_P_dangit( $text ) { |
| 4141 | 4225 | // Simple replacement for titles |
| 4142 | 4226 | $current_filter = current_filter(); |
| 4143 | - if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) |
|
| 4144 | - return str_replace( 'Wordpress', 'WordPress', $text ); |
|
| 4227 | + if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) { |
|
| 4228 | + return str_replace( 'Wordpress', 'WordPress', $text ); |
|
| 4229 | + } |
|
| 4145 | 4230 | // Still here? Use the more judicious replacement |
| 4146 | 4231 | static $dblq = false; |
| 4147 | 4232 | if ( false === $dblq ) { |
@@ -4185,8 +4270,9 @@ discard block |
||
| 4185 | 4270 | function sanitize_trackback_urls( $to_ping ) { |
| 4186 | 4271 | $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); |
| 4187 | 4272 | foreach ( $urls_to_ping as $k => $url ) { |
| 4188 | - if ( !preg_match( '#^https?://.#i', $url ) ) |
|
| 4189 | - unset( $urls_to_ping[$k] ); |
|
| 4273 | + if ( !preg_match( '#^https?://.#i', $url ) ) { |
|
| 4274 | + unset( $urls_to_ping[$k] ); |
|
| 4275 | + } |
|
| 4190 | 4276 | } |
| 4191 | 4277 | $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); |
| 4192 | 4278 | $urls_to_ping = implode( "\n", $urls_to_ping ); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', or PHP date |
| 57 | 57 | * format string (e.g. 'Y-m-d'). |
| 58 | - * @param int|bool $gmt Optional. Whether to use GMT timezone. Default false. |
|
| 58 | + * @param integer $gmt Optional. Whether to use GMT timezone. Default false. |
|
| 59 | 59 | * @return int|string Integer if $type is 'timestamp', string otherwise. |
| 60 | 60 | */ |
| 61 | 61 | function current_time( $type, $gmt = 0 ) { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * |
| 230 | 230 | * @param string $mysqlstring Date or datetime field type from MySQL. |
| 231 | 231 | * @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string. |
| 232 | - * @return array Keys are 'start' and 'end'. |
|
| 232 | + * @return string Keys are 'start' and 'end'. |
|
| 233 | 233 | */ |
| 234 | 234 | function get_weekstartend( $mysqlstring, $start_of_week = '' ) { |
| 235 | 235 | // MySQL string year. |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @since 2.0.5 |
| 378 | 378 | * |
| 379 | 379 | * @param string|array|object $data Data that might be serialized. |
| 380 | - * @return mixed A scalar data |
|
| 380 | + * @return string A scalar data |
|
| 381 | 381 | */ |
| 382 | 382 | function maybe_serialize( $data ) { |
| 383 | 383 | if ( is_array( $data ) || is_object( $data ) ) |
@@ -738,9 +738,6 @@ discard block |
||
| 738 | 738 | * |
| 739 | 739 | * @since 1.5.0 |
| 740 | 740 | * |
| 741 | - * @param string|array $param1 Either newkey or an associative_array. |
|
| 742 | - * @param string $param2 Either newvalue or oldquery or URI. |
|
| 743 | - * @param string $param3 Optional. Old query or URI. |
|
| 744 | 741 | * @return string New URL query string. |
| 745 | 742 | */ |
| 746 | 743 | function add_query_arg() { |
@@ -1343,7 +1340,7 @@ discard block |
||
| 1343 | 1340 | * @since 2.0.4 |
| 1344 | 1341 | * |
| 1345 | 1342 | * @param string $actionurl URL to add nonce action. |
| 1346 | - * @param int|string $action Optional. Nonce action name. Default -1. |
|
| 1343 | + * @param integer $action Optional. Nonce action name. Default -1. |
|
| 1347 | 1344 | * @param string $name Optional. Nonce name. Default '_wpnonce'. |
| 1348 | 1345 | * @return string Escaped URL with nonce action added. |
| 1349 | 1346 | */ |
@@ -1372,7 +1369,7 @@ discard block |
||
| 1372 | 1369 | * |
| 1373 | 1370 | * @since 2.0.4 |
| 1374 | 1371 | * |
| 1375 | - * @param int|string $action Optional. Action name. Default -1. |
|
| 1372 | + * @param integer $action Optional. Action name. Default -1. |
|
| 1376 | 1373 | * @param string $name Optional. Nonce name. Default '_wpnonce'. |
| 1377 | 1374 | * @param bool $referer Optional. Whether to set the referer field for validation. Default true. |
| 1378 | 1375 | * @param bool $echo Optional. Whether to display or return hidden form field. Default true. |
@@ -4349,7 +4346,7 @@ discard block |
||
| 4349 | 4346 | * |
| 4350 | 4347 | * @see __return_false() |
| 4351 | 4348 | * |
| 4352 | - * @return true True. |
|
| 4349 | + * @return boolean True. |
|
| 4353 | 4350 | */ |
| 4354 | 4351 | function __return_true() { |
| 4355 | 4352 | return true; |
@@ -4471,7 +4468,7 @@ discard block |
||
| 4471 | 4468 | * @param int $start The ID to start the loop check at. |
| 4472 | 4469 | * @param int $start_parent The parent_ID of $start to use instead of calling $callback( $start ). |
| 4473 | 4470 | * Use null to always use $callback |
| 4474 | - * @param array $callback_args Optional. Additional arguments to send to $callback. |
|
| 4471 | + * @param string[] $callback_args Optional. Additional arguments to send to $callback. |
|
| 4475 | 4472 | * @return array IDs of all members of loop. |
| 4476 | 4473 | */ |
| 4477 | 4474 | function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Main WordPress API |
|
| 4 | - * |
|
| 5 | - * @package WordPress |
|
| 6 | - */ |
|
| 3 | + * Main WordPress API |
|
| 4 | + * |
|
| 5 | + * @package WordPress |
|
| 6 | + */ |
|
| 7 | 7 | |
| 8 | 8 | require( ABSPATH . WPINC . '/option.php' ); |
| 9 | 9 | |
@@ -2284,14 +2284,14 @@ discard block |
||
| 2284 | 2284 | ) ); |
| 2285 | 2285 | } |
| 2286 | 2286 | /** |
| 2287 | - * Retrieve list of allowed mime types and file extensions. |
|
| 2288 | - * |
|
| 2289 | - * @since 2.8.6 |
|
| 2290 | - * |
|
| 2291 | - * @param int|WP_User $user Optional. User to check. Defaults to current user. |
|
| 2292 | - * @return array Array of mime types keyed by the file extension regex corresponding |
|
| 2293 | - * to those types. |
|
| 2294 | - */ |
|
| 2287 | + * Retrieve list of allowed mime types and file extensions. |
|
| 2288 | + * |
|
| 2289 | + * @since 2.8.6 |
|
| 2290 | + * |
|
| 2291 | + * @param int|WP_User $user Optional. User to check. Defaults to current user. |
|
| 2292 | + * @return array Array of mime types keyed by the file extension regex corresponding |
|
| 2293 | + * to those types. |
|
| 2294 | + */ |
|
| 2295 | 2295 | function get_allowed_mime_types( $user = null ) { |
| 2296 | 2296 | $t = wp_get_mime_types(); |
| 2297 | 2297 | |
@@ -2971,7 +2971,7 @@ discard block |
||
| 2971 | 2971 | ':arrow:' => "\xe2\x9e\xa1", |
| 2972 | 2972 | ':shock:' => "\xf0\x9f\x98\xaf", |
| 2973 | 2973 | ':smile:' => 'simple-smile.png', |
| 2974 | - ':???:' => "\xf0\x9f\x98\x95", |
|
| 2974 | + ':???:' => "\xf0\x9f\x98\x95", |
|
| 2975 | 2975 | ':cool:' => "\xf0\x9f\x98\x8e", |
| 2976 | 2976 | ':evil:' => "\xf0\x9f\x91\xbf", |
| 2977 | 2977 | ':grin:' => "\xf0\x9f\x98\x80", |
@@ -2980,36 +2980,36 @@ discard block |
||
| 2980 | 2980 | ':razz:' => "\xf0\x9f\x98\x9b", |
| 2981 | 2981 | ':roll:' => 'rolleyes.png', |
| 2982 | 2982 | ':wink:' => "\xf0\x9f\x98\x89", |
| 2983 | - ':cry:' => "\xf0\x9f\x98\xa5", |
|
| 2984 | - ':eek:' => "\xf0\x9f\x98\xae", |
|
| 2985 | - ':lol:' => "\xf0\x9f\x98\x86", |
|
| 2986 | - ':mad:' => "\xf0\x9f\x98\xa1", |
|
| 2987 | - ':sad:' => 'frownie.png', |
|
| 2988 | - '8-)' => "\xf0\x9f\x98\x8e", |
|
| 2989 | - '8-O' => "\xf0\x9f\x98\xaf", |
|
| 2990 | - ':-(' => 'frownie.png', |
|
| 2991 | - ':-)' => 'simple-smile.png', |
|
| 2992 | - ':-?' => "\xf0\x9f\x98\x95", |
|
| 2993 | - ':-D' => "\xf0\x9f\x98\x80", |
|
| 2994 | - ':-P' => "\xf0\x9f\x98\x9b", |
|
| 2995 | - ':-o' => "\xf0\x9f\x98\xae", |
|
| 2996 | - ':-x' => "\xf0\x9f\x98\xa1", |
|
| 2997 | - ':-|' => "\xf0\x9f\x98\x90", |
|
| 2998 | - ';-)' => "\xf0\x9f\x98\x89", |
|
| 2983 | + ':cry:' => "\xf0\x9f\x98\xa5", |
|
| 2984 | + ':eek:' => "\xf0\x9f\x98\xae", |
|
| 2985 | + ':lol:' => "\xf0\x9f\x98\x86", |
|
| 2986 | + ':mad:' => "\xf0\x9f\x98\xa1", |
|
| 2987 | + ':sad:' => 'frownie.png', |
|
| 2988 | + '8-)' => "\xf0\x9f\x98\x8e", |
|
| 2989 | + '8-O' => "\xf0\x9f\x98\xaf", |
|
| 2990 | + ':-(' => 'frownie.png', |
|
| 2991 | + ':-)' => 'simple-smile.png', |
|
| 2992 | + ':-?' => "\xf0\x9f\x98\x95", |
|
| 2993 | + ':-D' => "\xf0\x9f\x98\x80", |
|
| 2994 | + ':-P' => "\xf0\x9f\x98\x9b", |
|
| 2995 | + ':-o' => "\xf0\x9f\x98\xae", |
|
| 2996 | + ':-x' => "\xf0\x9f\x98\xa1", |
|
| 2997 | + ':-|' => "\xf0\x9f\x98\x90", |
|
| 2998 | + ';-)' => "\xf0\x9f\x98\x89", |
|
| 2999 | 2999 | // This one transformation breaks regular text with frequency. |
| 3000 | 3000 | // '8)' => "\xf0\x9f\x98\x8e", |
| 3001 | - '8O' => "\xf0\x9f\x98\xaf", |
|
| 3002 | - ':(' => 'frownie.png', |
|
| 3003 | - ':)' => 'simple-smile.png', |
|
| 3004 | - ':?' => "\xf0\x9f\x98\x95", |
|
| 3005 | - ':D' => "\xf0\x9f\x98\x80", |
|
| 3006 | - ':P' => "\xf0\x9f\x98\x9b", |
|
| 3007 | - ':o' => "\xf0\x9f\x98\xae", |
|
| 3008 | - ':x' => "\xf0\x9f\x98\xa1", |
|
| 3009 | - ':|' => "\xf0\x9f\x98\x90", |
|
| 3010 | - ';)' => "\xf0\x9f\x98\x89", |
|
| 3011 | - ':!:' => "\xe2\x9d\x97", |
|
| 3012 | - ':?:' => "\xe2\x9d\x93", |
|
| 3001 | + '8O' => "\xf0\x9f\x98\xaf", |
|
| 3002 | + ':(' => 'frownie.png', |
|
| 3003 | + ':)' => 'simple-smile.png', |
|
| 3004 | + ':?' => "\xf0\x9f\x98\x95", |
|
| 3005 | + ':D' => "\xf0\x9f\x98\x80", |
|
| 3006 | + ':P' => "\xf0\x9f\x98\x9b", |
|
| 3007 | + ':o' => "\xf0\x9f\x98\xae", |
|
| 3008 | + ':x' => "\xf0\x9f\x98\xa1", |
|
| 3009 | + ':|' => "\xf0\x9f\x98\x90", |
|
| 3010 | + ';)' => "\xf0\x9f\x98\x89", |
|
| 3011 | + ':!:' => "\xe2\x9d\x97", |
|
| 3012 | + ':?:' => "\xe2\x9d\x93", |
|
| 3013 | 3013 | ); |
| 3014 | 3014 | } |
| 3015 | 3015 | |
@@ -3519,31 +3519,31 @@ discard block |
||
| 3519 | 3519 | } |
| 3520 | 3520 | } |
| 3521 | 3521 | /** |
| 3522 | - * Mark a function argument as deprecated and inform when it has been used. |
|
| 3523 | - * |
|
| 3524 | - * This function is to be used whenever a deprecated function argument is used. |
|
| 3525 | - * Before this function is called, the argument must be checked for whether it was |
|
| 3526 | - * used by comparing it to its default value or evaluating whether it is empty. |
|
| 3527 | - * For example: |
|
| 3528 | - * |
|
| 3529 | - * if ( ! empty( $deprecated ) ) { |
|
| 3530 | - * _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 3531 | - * } |
|
| 3532 | - * |
|
| 3533 | - * |
|
| 3534 | - * There is a hook deprecated_argument_run that will be called that can be used |
|
| 3535 | - * to get the backtrace up to what file and function used the deprecated |
|
| 3536 | - * argument. |
|
| 3537 | - * |
|
| 3538 | - * The current behavior is to trigger a user error if WP_DEBUG is true. |
|
| 3539 | - * |
|
| 3540 | - * @since 3.0.0 |
|
| 3541 | - * @access private |
|
| 3542 | - * |
|
| 3543 | - * @param string $function The function that was called. |
|
| 3544 | - * @param string $version The version of WordPress that deprecated the argument used. |
|
| 3545 | - * @param string $message Optional. A message regarding the change. Default null. |
|
| 3546 | - */ |
|
| 3522 | + * Mark a function argument as deprecated and inform when it has been used. |
|
| 3523 | + * |
|
| 3524 | + * This function is to be used whenever a deprecated function argument is used. |
|
| 3525 | + * Before this function is called, the argument must be checked for whether it was |
|
| 3526 | + * used by comparing it to its default value or evaluating whether it is empty. |
|
| 3527 | + * For example: |
|
| 3528 | + * |
|
| 3529 | + * if ( ! empty( $deprecated ) ) { |
|
| 3530 | + * _deprecated_argument( __FUNCTION__, '3.0' ); |
|
| 3531 | + * } |
|
| 3532 | + * |
|
| 3533 | + * |
|
| 3534 | + * There is a hook deprecated_argument_run that will be called that can be used |
|
| 3535 | + * to get the backtrace up to what file and function used the deprecated |
|
| 3536 | + * argument. |
|
| 3537 | + * |
|
| 3538 | + * The current behavior is to trigger a user error if WP_DEBUG is true. |
|
| 3539 | + * |
|
| 3540 | + * @since 3.0.0 |
|
| 3541 | + * @access private |
|
| 3542 | + * |
|
| 3543 | + * @param string $function The function that was called. |
|
| 3544 | + * @param string $version The version of WordPress that deprecated the argument used. |
|
| 3545 | + * @param string $message Optional. A message regarding the change. Default null. |
|
| 3546 | + */ |
|
| 3547 | 3547 | function _deprecated_argument( $function, $version, $message = null ) { |
| 3548 | 3548 | |
| 3549 | 3549 | /** |
@@ -2440,15 +2440,15 @@ discard block |
||
| 2440 | 2440 | } |
| 2441 | 2441 | $errors = $message->get_error_messages(); |
| 2442 | 2442 | switch ( count( $errors ) ) { |
| 2443 | - case 0 : |
|
| 2444 | - $message = ''; |
|
| 2445 | - break; |
|
| 2446 | - case 1 : |
|
| 2447 | - $message = "<p>{$errors[0]}</p>"; |
|
| 2448 | - break; |
|
| 2449 | - default : |
|
| 2450 | - $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; |
|
| 2451 | - break; |
|
| 2443 | + case 0 : |
|
| 2444 | + $message = ''; |
|
| 2445 | + break; |
|
| 2446 | + case 1 : |
|
| 2447 | + $message = "<p>{$errors[0]}</p>"; |
|
| 2448 | + break; |
|
| 2449 | + default : |
|
| 2450 | + $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; |
|
| 2451 | + break; |
|
| 2452 | 2452 | } |
| 2453 | 2453 | } elseif ( is_string( $message ) ) { |
| 2454 | 2454 | $message = "<p>$message</p>"; |
@@ -4447,17 +4447,17 @@ discard block |
||
| 4447 | 4447 | */ |
| 4448 | 4448 | function _wp_mysql_week( $column ) { |
| 4449 | 4449 | switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { |
| 4450 | - case 1 : |
|
| 4451 | - return "WEEK( $column, 1 )"; |
|
| 4452 | - case 2 : |
|
| 4453 | - case 3 : |
|
| 4454 | - case 4 : |
|
| 4455 | - case 5 : |
|
| 4456 | - case 6 : |
|
| 4457 | - return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; |
|
| 4458 | - case 0 : |
|
| 4459 | - default : |
|
| 4460 | - return "WEEK( $column, 0 )"; |
|
| 4450 | + case 1 : |
|
| 4451 | + return "WEEK( $column, 1 )"; |
|
| 4452 | + case 2 : |
|
| 4453 | + case 3 : |
|
| 4454 | + case 4 : |
|
| 4455 | + case 5 : |
|
| 4456 | + case 6 : |
|
| 4457 | + return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; |
|
| 4458 | + case 0 : |
|
| 4459 | + default : |
|
| 4460 | + return "WEEK( $column, 0 )"; |
|
| 4461 | 4461 | } |
| 4462 | 4462 | } |
| 4463 | 4463 | |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @package WordPress |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -require( ABSPATH . WPINC . '/option.php' ); |
|
| 8 | +require(ABSPATH.WPINC.'/option.php'); |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Convert given date string into a different format. |
@@ -23,22 +23,22 @@ discard block |
||
| 23 | 23 | * @param bool $translate Whether the return date should be translated. Default true. |
| 24 | 24 | * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty. |
| 25 | 25 | */ |
| 26 | -function mysql2date( $format, $date, $translate = true ) { |
|
| 27 | - if ( empty( $date ) ) |
|
| 26 | +function mysql2date($format, $date, $translate = true) { |
|
| 27 | + if (empty($date)) |
|
| 28 | 28 | return false; |
| 29 | 29 | |
| 30 | - if ( 'G' == $format ) |
|
| 31 | - return strtotime( $date . ' +0000' ); |
|
| 30 | + if ('G' == $format) |
|
| 31 | + return strtotime($date.' +0000'); |
|
| 32 | 32 | |
| 33 | - $i = strtotime( $date ); |
|
| 33 | + $i = strtotime($date); |
|
| 34 | 34 | |
| 35 | - if ( 'U' == $format ) |
|
| 35 | + if ('U' == $format) |
|
| 36 | 36 | return $i; |
| 37 | 37 | |
| 38 | - if ( $translate ) |
|
| 39 | - return date_i18n( $format, $i ); |
|
| 38 | + if ($translate) |
|
| 39 | + return date_i18n($format, $i); |
|
| 40 | 40 | else |
| 41 | - return date( $format, $i ); |
|
| 41 | + return date($format, $i); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | * @param int|bool $gmt Optional. Whether to use GMT timezone. Default false. |
| 59 | 59 | * @return int|string Integer if $type is 'timestamp', string otherwise. |
| 60 | 60 | */ |
| 61 | -function current_time( $type, $gmt = 0 ) { |
|
| 62 | - switch ( $type ) { |
|
| 61 | +function current_time($type, $gmt = 0) { |
|
| 62 | + switch ($type) { |
|
| 63 | 63 | case 'mysql': |
| 64 | - return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ); |
|
| 64 | + return ($gmt) ? gmdate('Y-m-d H:i:s') : gmdate('Y-m-d H:i:s', (time() + (get_option('gmt_offset') * HOUR_IN_SECONDS))); |
|
| 65 | 65 | case 'timestamp': |
| 66 | - return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); |
|
| 66 | + return ($gmt) ? time() : time() + (get_option('gmt_offset') * HOUR_IN_SECONDS); |
|
| 67 | 67 | default: |
| 68 | - return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); |
|
| 68 | + return ($gmt) ? date($type) : date($type, time() + (get_option('gmt_offset') * HOUR_IN_SECONDS)); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return string The date, translated if locale specifies it. |
| 88 | 88 | */ |
| 89 | -function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { |
|
| 89 | +function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false) { |
|
| 90 | 90 | global $wp_locale; |
| 91 | 91 | $i = $unixtimestamp; |
| 92 | 92 | |
| 93 | - if ( false === $i ) { |
|
| 94 | - if ( ! $gmt ) |
|
| 95 | - $i = current_time( 'timestamp' ); |
|
| 93 | + if (false === $i) { |
|
| 94 | + if ( ! $gmt) |
|
| 95 | + $i = current_time('timestamp'); |
|
| 96 | 96 | else |
| 97 | 97 | $i = time(); |
| 98 | 98 | // we should not let date() interfere with our |
@@ -106,43 +106,43 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | $req_format = $dateformatstring; |
| 108 | 108 | |
| 109 | - $datefunc = $gmt? 'gmdate' : 'date'; |
|
| 109 | + $datefunc = $gmt ? 'gmdate' : 'date'; |
|
| 110 | 110 | |
| 111 | - if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { |
|
| 112 | - $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); |
|
| 113 | - $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); |
|
| 114 | - $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); |
|
| 115 | - $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); |
|
| 116 | - $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); |
|
| 117 | - $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); |
|
| 111 | + if (( ! empty($wp_locale->month)) && ( ! empty($wp_locale->weekday))) { |
|
| 112 | + $datemonth = $wp_locale->get_month($datefunc('m', $i)); |
|
| 113 | + $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth); |
|
| 114 | + $dateweekday = $wp_locale->get_weekday($datefunc('w', $i)); |
|
| 115 | + $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday); |
|
| 116 | + $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i)); |
|
| 117 | + $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i)); |
|
| 118 | 118 | $dateformatstring = ' '.$dateformatstring; |
| 119 | - $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); |
|
| 120 | - $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); |
|
| 121 | - $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring ); |
|
| 122 | - $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); |
|
| 123 | - $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring ); |
|
| 124 | - $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); |
|
| 125 | - |
|
| 126 | - $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); |
|
| 119 | + $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); |
|
| 120 | + $dateformatstring = preg_replace("/([^\\\])F/", "\\1".backslashit($datemonth), $dateformatstring); |
|
| 121 | + $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); |
|
| 122 | + $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring); |
|
| 123 | + $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring); |
|
| 124 | + $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring); |
|
| 125 | + |
|
| 126 | + $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1); |
|
| 127 | 127 | } |
| 128 | - $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); |
|
| 129 | - $timezone_formats_re = implode( '|', $timezone_formats ); |
|
| 130 | - if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) { |
|
| 131 | - $timezone_string = get_option( 'timezone_string' ); |
|
| 132 | - if ( $timezone_string ) { |
|
| 133 | - $timezone_object = timezone_open( $timezone_string ); |
|
| 134 | - $date_object = date_create( null, $timezone_object ); |
|
| 135 | - foreach( $timezone_formats as $timezone_format ) { |
|
| 136 | - if ( false !== strpos( $dateformatstring, $timezone_format ) ) { |
|
| 137 | - $formatted = date_format( $date_object, $timezone_format ); |
|
| 128 | + $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e'); |
|
| 129 | + $timezone_formats_re = implode('|', $timezone_formats); |
|
| 130 | + if (preg_match("/$timezone_formats_re/", $dateformatstring)) { |
|
| 131 | + $timezone_string = get_option('timezone_string'); |
|
| 132 | + if ($timezone_string) { |
|
| 133 | + $timezone_object = timezone_open($timezone_string); |
|
| 134 | + $date_object = date_create(null, $timezone_object); |
|
| 135 | + foreach ($timezone_formats as $timezone_format) { |
|
| 136 | + if (false !== strpos($dateformatstring, $timezone_format)) { |
|
| 137 | + $formatted = date_format($date_object, $timezone_format); |
|
| 138 | 138 | $dateformatstring = ' '.$dateformatstring; |
| 139 | - $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); |
|
| 140 | - $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); |
|
| 139 | + $dateformatstring = preg_replace("/([^\\\])$timezone_format/", "\\1".backslashit($formatted), $dateformatstring); |
|
| 140 | + $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1); |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | - $j = @$datefunc( $dateformatstring, $i ); |
|
| 145 | + $j = @$datefunc($dateformatstring, $i); |
|
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | 148 | * Filter the date formatted based on the locale. |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param int $i Unix timestamp. |
| 155 | 155 | * @param bool $gmt Whether to convert to GMT for time. Default false. |
| 156 | 156 | */ |
| 157 | - $j = apply_filters( 'date_i18n', $j, $req_format, $i, $gmt ); |
|
| 157 | + $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt); |
|
| 158 | 158 | return $j; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | * @param int $decimals Optional. Precision of the number of decimal places. Default 0. |
| 170 | 170 | * @return string Converted number in string format. |
| 171 | 171 | */ |
| 172 | -function number_format_i18n( $number, $decimals = 0 ) { |
|
| 172 | +function number_format_i18n($number, $decimals = 0) { |
|
| 173 | 173 | global $wp_locale; |
| 174 | - $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); |
|
| 174 | + $formatted = number_format($number, absint($decimals), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep']); |
|
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | 177 | * Filter the number formatted based on the locale. |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * |
| 181 | 181 | * @param string $formatted Converted number in string format. |
| 182 | 182 | */ |
| 183 | - return apply_filters( 'number_format_i18n', $formatted ); |
|
| 183 | + return apply_filters('number_format_i18n', $formatted); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -203,19 +203,19 @@ discard block |
||
| 203 | 203 | * @param int $decimals Optional. Precision of number of decimal places. Default 0. |
| 204 | 204 | * @return string|false False on failure. Number string on success. |
| 205 | 205 | */ |
| 206 | -function size_format( $bytes, $decimals = 0 ) { |
|
| 206 | +function size_format($bytes, $decimals = 0) { |
|
| 207 | 207 | $quant = array( |
| 208 | 208 | // ========================= Origin ==== |
| 209 | - 'TB' => 1099511627776, // pow( 1024, 4) |
|
| 210 | - 'GB' => 1073741824, // pow( 1024, 3) |
|
| 211 | - 'MB' => 1048576, // pow( 1024, 2) |
|
| 212 | - 'kB' => 1024, // pow( 1024, 1) |
|
| 213 | - 'B' => 1, // pow( 1024, 0) |
|
| 209 | + 'TB' => 1099511627776, // pow( 1024, 4) |
|
| 210 | + 'GB' => 1073741824, // pow( 1024, 3) |
|
| 211 | + 'MB' => 1048576, // pow( 1024, 2) |
|
| 212 | + 'kB' => 1024, // pow( 1024, 1) |
|
| 213 | + 'B' => 1, // pow( 1024, 0) |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - foreach ( $quant as $unit => $mag ) { |
|
| 217 | - if ( doubleval( $bytes ) >= $mag ) { |
|
| 218 | - return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; |
|
| 216 | + foreach ($quant as $unit => $mag) { |
|
| 217 | + if (doubleval($bytes) >= $mag) { |
|
| 218 | + return number_format_i18n($bytes / $mag, $decimals).' '.$unit; |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -231,34 +231,34 @@ discard block |
||
| 231 | 231 | * @param int|string $start_of_week Optional. Start of the week as an integer. Default empty string. |
| 232 | 232 | * @return array Keys are 'start' and 'end'. |
| 233 | 233 | */ |
| 234 | -function get_weekstartend( $mysqlstring, $start_of_week = '' ) { |
|
| 234 | +function get_weekstartend($mysqlstring, $start_of_week = '') { |
|
| 235 | 235 | // MySQL string year. |
| 236 | - $my = substr( $mysqlstring, 0, 4 ); |
|
| 236 | + $my = substr($mysqlstring, 0, 4); |
|
| 237 | 237 | |
| 238 | 238 | // MySQL string month. |
| 239 | - $mm = substr( $mysqlstring, 8, 2 ); |
|
| 239 | + $mm = substr($mysqlstring, 8, 2); |
|
| 240 | 240 | |
| 241 | 241 | // MySQL string day. |
| 242 | - $md = substr( $mysqlstring, 5, 2 ); |
|
| 242 | + $md = substr($mysqlstring, 5, 2); |
|
| 243 | 243 | |
| 244 | 244 | // The timestamp for MySQL string day. |
| 245 | - $day = mktime( 0, 0, 0, $md, $mm, $my ); |
|
| 245 | + $day = mktime(0, 0, 0, $md, $mm, $my); |
|
| 246 | 246 | |
| 247 | 247 | // The day of the week from the timestamp. |
| 248 | - $weekday = date( 'w', $day ); |
|
| 248 | + $weekday = date('w', $day); |
|
| 249 | 249 | |
| 250 | - if ( !is_numeric($start_of_week) ) |
|
| 251 | - $start_of_week = get_option( 'start_of_week' ); |
|
| 250 | + if ( ! is_numeric($start_of_week)) |
|
| 251 | + $start_of_week = get_option('start_of_week'); |
|
| 252 | 252 | |
| 253 | - if ( $weekday < $start_of_week ) |
|
| 253 | + if ($weekday < $start_of_week) |
|
| 254 | 254 | $weekday += 7; |
| 255 | 255 | |
| 256 | 256 | // The most recent week start day on or before $day. |
| 257 | - $start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); |
|
| 257 | + $start = $day - DAY_IN_SECONDS * ($weekday - $start_of_week); |
|
| 258 | 258 | |
| 259 | 259 | // $start + 7 days - 1 second. |
| 260 | 260 | $end = $start + 7 * DAY_IN_SECONDS - 1; |
| 261 | - return compact( 'start', 'end' ); |
|
| 261 | + return compact('start', 'end'); |
|
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
@@ -269,9 +269,9 @@ discard block |
||
| 269 | 269 | * @param string $original Maybe unserialized original, if is needed. |
| 270 | 270 | * @return mixed Unserialized data can be any type. |
| 271 | 271 | */ |
| 272 | -function maybe_unserialize( $original ) { |
|
| 273 | - if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in |
|
| 274 | - return @unserialize( $original ); |
|
| 272 | +function maybe_unserialize($original) { |
|
| 273 | + if (is_serialized($original)) // don't attempt to unserialize data that wasn't serialized going in |
|
| 274 | + return @unserialize($original); |
|
| 275 | 275 | return $original; |
| 276 | 276 | } |
| 277 | 277 | |
@@ -287,57 +287,57 @@ discard block |
||
| 287 | 287 | * @param bool $strict Optional. Whether to be strict about the end of the string. Default true. |
| 288 | 288 | * @return bool False if not serialized and true if it was. |
| 289 | 289 | */ |
| 290 | -function is_serialized( $data, $strict = true ) { |
|
| 290 | +function is_serialized($data, $strict = true) { |
|
| 291 | 291 | // if it isn't a string, it isn't serialized. |
| 292 | - if ( ! is_string( $data ) ) { |
|
| 292 | + if ( ! is_string($data)) { |
|
| 293 | 293 | return false; |
| 294 | 294 | } |
| 295 | - $data = trim( $data ); |
|
| 296 | - if ( 'N;' == $data ) { |
|
| 295 | + $data = trim($data); |
|
| 296 | + if ('N;' == $data) { |
|
| 297 | 297 | return true; |
| 298 | 298 | } |
| 299 | - if ( strlen( $data ) < 4 ) { |
|
| 299 | + if (strlen($data) < 4) { |
|
| 300 | 300 | return false; |
| 301 | 301 | } |
| 302 | - if ( ':' !== $data[1] ) { |
|
| 302 | + if (':' !== $data[1]) { |
|
| 303 | 303 | return false; |
| 304 | 304 | } |
| 305 | - if ( $strict ) { |
|
| 306 | - $lastc = substr( $data, -1 ); |
|
| 307 | - if ( ';' !== $lastc && '}' !== $lastc ) { |
|
| 305 | + if ($strict) { |
|
| 306 | + $lastc = substr($data, -1); |
|
| 307 | + if (';' !== $lastc && '}' !== $lastc) { |
|
| 308 | 308 | return false; |
| 309 | 309 | } |
| 310 | 310 | } else { |
| 311 | - $semicolon = strpos( $data, ';' ); |
|
| 312 | - $brace = strpos( $data, '}' ); |
|
| 311 | + $semicolon = strpos($data, ';'); |
|
| 312 | + $brace = strpos($data, '}'); |
|
| 313 | 313 | // Either ; or } must exist. |
| 314 | - if ( false === $semicolon && false === $brace ) |
|
| 314 | + if (false === $semicolon && false === $brace) |
|
| 315 | 315 | return false; |
| 316 | 316 | // But neither must be in the first X characters. |
| 317 | - if ( false !== $semicolon && $semicolon < 3 ) |
|
| 317 | + if (false !== $semicolon && $semicolon < 3) |
|
| 318 | 318 | return false; |
| 319 | - if ( false !== $brace && $brace < 4 ) |
|
| 319 | + if (false !== $brace && $brace < 4) |
|
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | 322 | $token = $data[0]; |
| 323 | - switch ( $token ) { |
|
| 323 | + switch ($token) { |
|
| 324 | 324 | case 's' : |
| 325 | - if ( $strict ) { |
|
| 326 | - if ( '"' !== substr( $data, -2, 1 ) ) { |
|
| 325 | + if ($strict) { |
|
| 326 | + if ('"' !== substr($data, -2, 1)) { |
|
| 327 | 327 | return false; |
| 328 | 328 | } |
| 329 | - } elseif ( false === strpos( $data, '"' ) ) { |
|
| 329 | + } elseif (false === strpos($data, '"')) { |
|
| 330 | 330 | return false; |
| 331 | 331 | } |
| 332 | 332 | // or else fall through |
| 333 | 333 | case 'a' : |
| 334 | 334 | case 'O' : |
| 335 | - return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); |
|
| 335 | + return (bool) preg_match("/^{$token}:[0-9]+:/s", $data); |
|
| 336 | 336 | case 'b' : |
| 337 | 337 | case 'i' : |
| 338 | 338 | case 'd' : |
| 339 | 339 | $end = $strict ? '$' : ''; |
| 340 | - return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); |
|
| 340 | + return (bool) preg_match("/^{$token}:[0-9.E-]+;$end/", $data); |
|
| 341 | 341 | } |
| 342 | 342 | return false; |
| 343 | 343 | } |
@@ -350,21 +350,21 @@ discard block |
||
| 350 | 350 | * @param string $data Serialized data. |
| 351 | 351 | * @return bool False if not a serialized string, true if it is. |
| 352 | 352 | */ |
| 353 | -function is_serialized_string( $data ) { |
|
| 353 | +function is_serialized_string($data) { |
|
| 354 | 354 | // if it isn't a string, it isn't a serialized string. |
| 355 | - if ( ! is_string( $data ) ) { |
|
| 355 | + if ( ! is_string($data)) { |
|
| 356 | 356 | return false; |
| 357 | 357 | } |
| 358 | - $data = trim( $data ); |
|
| 359 | - if ( strlen( $data ) < 4 ) { |
|
| 358 | + $data = trim($data); |
|
| 359 | + if (strlen($data) < 4) { |
|
| 360 | 360 | return false; |
| 361 | - } elseif ( ':' !== $data[1] ) { |
|
| 361 | + } elseif (':' !== $data[1]) { |
|
| 362 | 362 | return false; |
| 363 | - } elseif ( ';' !== substr( $data, -1 ) ) { |
|
| 363 | + } elseif (';' !== substr($data, -1)) { |
|
| 364 | 364 | return false; |
| 365 | - } elseif ( $data[0] !== 's' ) { |
|
| 365 | + } elseif ($data[0] !== 's') { |
|
| 366 | 366 | return false; |
| 367 | - } elseif ( '"' !== substr( $data, -2, 1 ) ) { |
|
| 367 | + } elseif ('"' !== substr($data, -2, 1)) { |
|
| 368 | 368 | return false; |
| 369 | 369 | } else { |
| 370 | 370 | return true; |
@@ -379,15 +379,15 @@ discard block |
||
| 379 | 379 | * @param string|array|object $data Data that might be serialized. |
| 380 | 380 | * @return mixed A scalar data |
| 381 | 381 | */ |
| 382 | -function maybe_serialize( $data ) { |
|
| 383 | - if ( is_array( $data ) || is_object( $data ) ) |
|
| 384 | - return serialize( $data ); |
|
| 382 | +function maybe_serialize($data) { |
|
| 383 | + if (is_array($data) || is_object($data)) |
|
| 384 | + return serialize($data); |
|
| 385 | 385 | |
| 386 | 386 | // Double serialization is required for backward compatibility. |
| 387 | 387 | // See https://core.trac.wordpress.org/ticket/12930 |
| 388 | 388 | // Also the world will end. See WP 3.6.1. |
| 389 | - if ( is_serialized( $data, false ) ) |
|
| 390 | - return serialize( $data ); |
|
| 389 | + if (is_serialized($data, false)) |
|
| 390 | + return serialize($data); |
|
| 391 | 391 | |
| 392 | 392 | return $data; |
| 393 | 393 | } |
@@ -405,9 +405,9 @@ discard block |
||
| 405 | 405 | * @param string $content XMLRPC XML Request content |
| 406 | 406 | * @return string Post title |
| 407 | 407 | */ |
| 408 | -function xmlrpc_getposttitle( $content ) { |
|
| 408 | +function xmlrpc_getposttitle($content) { |
|
| 409 | 409 | global $post_default_title; |
| 410 | - if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) { |
|
| 410 | + if (preg_match('/<title>(.+?)<\/title>/is', $content, $matchtitle)) { |
|
| 411 | 411 | $post_title = $matchtitle[1]; |
| 412 | 412 | } else { |
| 413 | 413 | $post_title = $post_default_title; |
@@ -429,11 +429,11 @@ discard block |
||
| 429 | 429 | * @param string $content XMLRPC XML Request content |
| 430 | 430 | * @return string|array List of categories or category name. |
| 431 | 431 | */ |
| 432 | -function xmlrpc_getpostcategory( $content ) { |
|
| 432 | +function xmlrpc_getpostcategory($content) { |
|
| 433 | 433 | global $post_default_category; |
| 434 | - if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { |
|
| 435 | - $post_category = trim( $matchcat[1], ',' ); |
|
| 436 | - $post_category = explode( ',', $post_category ); |
|
| 434 | + if (preg_match('/<category>(.+?)<\/category>/is', $content, $matchcat)) { |
|
| 435 | + $post_category = trim($matchcat[1], ','); |
|
| 436 | + $post_category = explode(',', $post_category); |
|
| 437 | 437 | } else { |
| 438 | 438 | $post_category = $post_default_category; |
| 439 | 439 | } |
@@ -448,10 +448,10 @@ discard block |
||
| 448 | 448 | * @param string $content XML-RPC XML Request content. |
| 449 | 449 | * @return string XMLRPC XML Request content without title and category elements. |
| 450 | 450 | */ |
| 451 | -function xmlrpc_removepostdata( $content ) { |
|
| 452 | - $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); |
|
| 453 | - $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); |
|
| 454 | - $content = trim( $content ); |
|
| 451 | +function xmlrpc_removepostdata($content) { |
|
| 452 | + $content = preg_replace('/<title>(.+?)<\/title>/si', '', $content); |
|
| 453 | + $content = preg_replace('/<category>(.+?)<\/category>/si', '', $content); |
|
| 454 | + $content = trim($content); |
|
| 455 | 455 | return $content; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param string $content Content to extract URLs from. |
| 464 | 464 | * @return array URLs found in passed string. |
| 465 | 465 | */ |
| 466 | -function wp_extract_urls( $content ) { |
|
| 466 | +function wp_extract_urls($content) { |
|
| 467 | 467 | preg_match_all( |
| 468 | 468 | "#([\"']?)(" |
| 469 | 469 | . "(?:([\w-]+:)?//?)" |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | $post_links |
| 482 | 482 | ); |
| 483 | 483 | |
| 484 | - $post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) ); |
|
| 484 | + $post_links = array_unique(array_map('html_entity_decode', $post_links[2])); |
|
| 485 | 485 | |
| 486 | - return array_values( $post_links ); |
|
| 486 | + return array_values($post_links); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -500,54 +500,54 @@ discard block |
||
| 500 | 500 | * @param string $content Post Content. |
| 501 | 501 | * @param int $post_ID Post ID. |
| 502 | 502 | */ |
| 503 | -function do_enclose( $content, $post_ID ) { |
|
| 503 | +function do_enclose($content, $post_ID) { |
|
| 504 | 504 | global $wpdb; |
| 505 | 505 | |
| 506 | 506 | //TODO: Tidy this ghetto code up and make the debug code optional |
| 507 | - include_once( ABSPATH . WPINC . '/class-IXR.php' ); |
|
| 507 | + include_once(ABSPATH.WPINC.'/class-IXR.php'); |
|
| 508 | 508 | |
| 509 | 509 | $post_links = array(); |
| 510 | 510 | |
| 511 | - $pung = get_enclosed( $post_ID ); |
|
| 511 | + $pung = get_enclosed($post_ID); |
|
| 512 | 512 | |
| 513 | - $post_links_temp = wp_extract_urls( $content ); |
|
| 513 | + $post_links_temp = wp_extract_urls($content); |
|
| 514 | 514 | |
| 515 | - foreach ( $pung as $link_test ) { |
|
| 516 | - if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post |
|
| 517 | - $mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%') ); |
|
| 518 | - foreach ( $mids as $mid ) |
|
| 519 | - delete_metadata_by_mid( 'post', $mid ); |
|
| 515 | + foreach ($pung as $link_test) { |
|
| 516 | + if ( ! in_array($link_test, $post_links_temp)) { // link no longer in post |
|
| 517 | + $mids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($link_test).'%')); |
|
| 518 | + foreach ($mids as $mid) |
|
| 519 | + delete_metadata_by_mid('post', $mid); |
|
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - foreach ( (array) $post_links_temp as $link_test ) { |
|
| 524 | - if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already |
|
| 525 | - $test = @parse_url( $link_test ); |
|
| 526 | - if ( false === $test ) |
|
| 523 | + foreach ((array) $post_links_temp as $link_test) { |
|
| 524 | + if ( ! in_array($link_test, $pung)) { // If we haven't pung it already |
|
| 525 | + $test = @parse_url($link_test); |
|
| 526 | + if (false === $test) |
|
| 527 | 527 | continue; |
| 528 | - if ( isset( $test['query'] ) ) |
|
| 528 | + if (isset($test['query'])) |
|
| 529 | 529 | $post_links[] = $link_test; |
| 530 | - elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) ) |
|
| 530 | + elseif (isset($test['path']) && ($test['path'] != '/') && ($test['path'] != '')) |
|
| 531 | 531 | $post_links[] = $link_test; |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - foreach ( (array) $post_links as $url ) { |
|
| 536 | - if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) { |
|
| 535 | + foreach ((array) $post_links as $url) { |
|
| 536 | + if ($url != '' && ! $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like($url).'%'))) { |
|
| 537 | 537 | |
| 538 | - if ( $headers = wp_get_http_headers( $url) ) { |
|
| 539 | - $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; |
|
| 540 | - $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; |
|
| 541 | - $allowed_types = array( 'video', 'audio' ); |
|
| 538 | + if ($headers = wp_get_http_headers($url)) { |
|
| 539 | + $len = isset($headers['content-length']) ? (int) $headers['content-length'] : 0; |
|
| 540 | + $type = isset($headers['content-type']) ? $headers['content-type'] : ''; |
|
| 541 | + $allowed_types = array('video', 'audio'); |
|
| 542 | 542 | |
| 543 | 543 | // Check to see if we can figure out the mime type from |
| 544 | 544 | // the extension |
| 545 | - $url_parts = @parse_url( $url ); |
|
| 546 | - if ( false !== $url_parts ) { |
|
| 547 | - $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); |
|
| 548 | - if ( !empty( $extension ) ) { |
|
| 549 | - foreach ( wp_get_mime_types() as $exts => $mime ) { |
|
| 550 | - if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { |
|
| 545 | + $url_parts = @parse_url($url); |
|
| 546 | + if (false !== $url_parts) { |
|
| 547 | + $extension = pathinfo($url_parts['path'], PATHINFO_EXTENSION); |
|
| 548 | + if ( ! empty($extension)) { |
|
| 549 | + foreach (wp_get_mime_types() as $exts => $mime) { |
|
| 550 | + if (preg_match('!^('.$exts.')$!i', $extension)) { |
|
| 551 | 551 | $type = $mime; |
| 552 | 552 | break; |
| 553 | 553 | } |
@@ -555,8 +555,8 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { |
|
| 559 | - add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" ); |
|
| 558 | + if (in_array(substr($type, 0, strpos($type, "/")), $allowed_types)) { |
|
| 559 | + add_post_meta($post_ID, 'enclosure', "$url\n$len\n$mime\n"); |
|
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | } |
@@ -577,42 +577,42 @@ discard block |
||
| 577 | 577 | * returns false. Default 1. |
| 578 | 578 | * @return bool|string False on failure and string of headers if HEAD request. |
| 579 | 579 | */ |
| 580 | -function wp_get_http( $url, $file_path = false, $red = 1 ) { |
|
| 581 | - @set_time_limit( 60 ); |
|
| 580 | +function wp_get_http($url, $file_path = false, $red = 1) { |
|
| 581 | + @set_time_limit(60); |
|
| 582 | 582 | |
| 583 | - if ( $red > 5 ) |
|
| 583 | + if ($red > 5) |
|
| 584 | 584 | return false; |
| 585 | 585 | |
| 586 | 586 | $options = array(); |
| 587 | 587 | $options['redirection'] = 5; |
| 588 | 588 | |
| 589 | - if ( false == $file_path ) |
|
| 589 | + if (false == $file_path) |
|
| 590 | 590 | $options['method'] = 'HEAD'; |
| 591 | 591 | else |
| 592 | 592 | $options['method'] = 'GET'; |
| 593 | 593 | |
| 594 | - $response = wp_safe_remote_request( $url, $options ); |
|
| 594 | + $response = wp_safe_remote_request($url, $options); |
|
| 595 | 595 | |
| 596 | - if ( is_wp_error( $response ) ) |
|
| 596 | + if (is_wp_error($response)) |
|
| 597 | 597 | return false; |
| 598 | 598 | |
| 599 | - $headers = wp_remote_retrieve_headers( $response ); |
|
| 600 | - $headers['response'] = wp_remote_retrieve_response_code( $response ); |
|
| 599 | + $headers = wp_remote_retrieve_headers($response); |
|
| 600 | + $headers['response'] = wp_remote_retrieve_response_code($response); |
|
| 601 | 601 | |
| 602 | 602 | // WP_HTTP no longer follows redirects for HEAD requests. |
| 603 | - if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { |
|
| 604 | - return wp_get_http( $headers['location'], $file_path, ++$red ); |
|
| 603 | + if ('HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset($headers['location'])) { |
|
| 604 | + return wp_get_http($headers['location'], $file_path, ++$red); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - if ( false == $file_path ) |
|
| 607 | + if (false == $file_path) |
|
| 608 | 608 | return $headers; |
| 609 | 609 | |
| 610 | 610 | // GET request - write it to the supplied filename |
| 611 | 611 | $out_fp = fopen($file_path, 'w'); |
| 612 | - if ( !$out_fp ) |
|
| 612 | + if ( ! $out_fp) |
|
| 613 | 613 | return $headers; |
| 614 | 614 | |
| 615 | - fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); |
|
| 615 | + fwrite($out_fp, wp_remote_retrieve_body($response)); |
|
| 616 | 616 | fclose($out_fp); |
| 617 | 617 | clearstatcache(); |
| 618 | 618 | |
@@ -628,16 +628,16 @@ discard block |
||
| 628 | 628 | * @param bool $deprecated Not Used. |
| 629 | 629 | * @return bool|string False on failure, headers on success. |
| 630 | 630 | */ |
| 631 | -function wp_get_http_headers( $url, $deprecated = false ) { |
|
| 632 | - if ( !empty( $deprecated ) ) |
|
| 633 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 631 | +function wp_get_http_headers($url, $deprecated = false) { |
|
| 632 | + if ( ! empty($deprecated)) |
|
| 633 | + _deprecated_argument(__FUNCTION__, '2.7'); |
|
| 634 | 634 | |
| 635 | - $response = wp_safe_remote_head( $url ); |
|
| 635 | + $response = wp_safe_remote_head($url); |
|
| 636 | 636 | |
| 637 | - if ( is_wp_error( $response ) ) |
|
| 637 | + if (is_wp_error($response)) |
|
| 638 | 638 | return false; |
| 639 | 639 | |
| 640 | - return wp_remote_retrieve_headers( $response ); |
|
| 640 | + return wp_remote_retrieve_headers($response); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | */ |
| 654 | 654 | function is_new_day() { |
| 655 | 655 | global $currentday, $previousday; |
| 656 | - if ( $currentday != $previousday ) |
|
| 656 | + if ($currentday != $previousday) |
|
| 657 | 657 | return 1; |
| 658 | 658 | else |
| 659 | 659 | return 0; |
@@ -674,8 +674,8 @@ discard block |
||
| 674 | 674 | * @param array $data URL-encode key/value pairs. |
| 675 | 675 | * @return string URL-encoded string. |
| 676 | 676 | */ |
| 677 | -function build_query( $data ) { |
|
| 678 | - return _http_build_query( $data, null, '&', '', false ); |
|
| 677 | +function build_query($data) { |
|
| 678 | + return _http_build_query($data, null, '&', '', false); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -696,30 +696,30 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @return string The query string. |
| 698 | 698 | */ |
| 699 | -function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urlencode = true ) { |
|
| 699 | +function _http_build_query($data, $prefix = null, $sep = null, $key = '', $urlencode = true) { |
|
| 700 | 700 | $ret = array(); |
| 701 | 701 | |
| 702 | - foreach ( (array) $data as $k => $v ) { |
|
| 703 | - if ( $urlencode) |
|
| 702 | + foreach ((array) $data as $k => $v) { |
|
| 703 | + if ($urlencode) |
|
| 704 | 704 | $k = urlencode($k); |
| 705 | - if ( is_int($k) && $prefix != null ) |
|
| 705 | + if (is_int($k) && $prefix != null) |
|
| 706 | 706 | $k = $prefix.$k; |
| 707 | - if ( !empty($key) ) |
|
| 708 | - $k = $key . '%5B' . $k . '%5D'; |
|
| 709 | - if ( $v === null ) |
|
| 707 | + if ( ! empty($key)) |
|
| 708 | + $k = $key.'%5B'.$k.'%5D'; |
|
| 709 | + if ($v === null) |
|
| 710 | 710 | continue; |
| 711 | - elseif ( $v === false ) |
|
| 711 | + elseif ($v === false) |
|
| 712 | 712 | $v = '0'; |
| 713 | 713 | |
| 714 | - if ( is_array($v) || is_object($v) ) |
|
| 715 | - array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); |
|
| 716 | - elseif ( $urlencode ) |
|
| 714 | + if (is_array($v) || is_object($v)) |
|
| 715 | + array_push($ret, _http_build_query($v, '', $sep, $k, $urlencode)); |
|
| 716 | + elseif ($urlencode) |
|
| 717 | 717 | array_push($ret, $k.'='.urlencode($v)); |
| 718 | 718 | else |
| 719 | 719 | array_push($ret, $k.'='.$v); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | - if ( null === $sep ) |
|
| 722 | + if (null === $sep) |
|
| 723 | 723 | $sep = ini_get('arg_separator.output'); |
| 724 | 724 | |
| 725 | 725 | return implode($sep, $ret); |
@@ -745,64 +745,64 @@ discard block |
||
| 745 | 745 | */ |
| 746 | 746 | function add_query_arg() { |
| 747 | 747 | $args = func_get_args(); |
| 748 | - if ( is_array( $args[0] ) ) { |
|
| 749 | - if ( count( $args ) < 2 || false === $args[1] ) |
|
| 748 | + if (is_array($args[0])) { |
|
| 749 | + if (count($args) < 2 || false === $args[1]) |
|
| 750 | 750 | $uri = $_SERVER['REQUEST_URI']; |
| 751 | 751 | else |
| 752 | 752 | $uri = $args[1]; |
| 753 | 753 | } else { |
| 754 | - if ( count( $args ) < 3 || false === $args[2] ) |
|
| 754 | + if (count($args) < 3 || false === $args[2]) |
|
| 755 | 755 | $uri = $_SERVER['REQUEST_URI']; |
| 756 | 756 | else |
| 757 | 757 | $uri = $args[2]; |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - if ( $frag = strstr( $uri, '#' ) ) |
|
| 761 | - $uri = substr( $uri, 0, -strlen( $frag ) ); |
|
| 760 | + if ($frag = strstr($uri, '#')) |
|
| 761 | + $uri = substr($uri, 0, -strlen($frag)); |
|
| 762 | 762 | else |
| 763 | 763 | $frag = ''; |
| 764 | 764 | |
| 765 | - if ( 0 === stripos( $uri, 'http://' ) ) { |
|
| 765 | + if (0 === stripos($uri, 'http://')) { |
|
| 766 | 766 | $protocol = 'http://'; |
| 767 | - $uri = substr( $uri, 7 ); |
|
| 768 | - } elseif ( 0 === stripos( $uri, 'https://' ) ) { |
|
| 767 | + $uri = substr($uri, 7); |
|
| 768 | + } elseif (0 === stripos($uri, 'https://')) { |
|
| 769 | 769 | $protocol = 'https://'; |
| 770 | - $uri = substr( $uri, 8 ); |
|
| 770 | + $uri = substr($uri, 8); |
|
| 771 | 771 | } else { |
| 772 | 772 | $protocol = ''; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if ( strpos( $uri, '?' ) !== false ) { |
|
| 776 | - list( $base, $query ) = explode( '?', $uri, 2 ); |
|
| 775 | + if (strpos($uri, '?') !== false) { |
|
| 776 | + list($base, $query) = explode('?', $uri, 2); |
|
| 777 | 777 | $base .= '?'; |
| 778 | - } elseif ( $protocol || strpos( $uri, '=' ) === false ) { |
|
| 779 | - $base = $uri . '?'; |
|
| 778 | + } elseif ($protocol || strpos($uri, '=') === false) { |
|
| 779 | + $base = $uri.'?'; |
|
| 780 | 780 | $query = ''; |
| 781 | 781 | } else { |
| 782 | 782 | $base = ''; |
| 783 | 783 | $query = $uri; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - wp_parse_str( $query, $qs ); |
|
| 787 | - $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string |
|
| 788 | - if ( is_array( $args[0] ) ) { |
|
| 789 | - foreach ( $args[0] as $k => $v ) { |
|
| 790 | - $qs[ $k ] = $v; |
|
| 786 | + wp_parse_str($query, $qs); |
|
| 787 | + $qs = urlencode_deep($qs); // this re-URL-encodes things that were already in the query string |
|
| 788 | + if (is_array($args[0])) { |
|
| 789 | + foreach ($args[0] as $k => $v) { |
|
| 790 | + $qs[$k] = $v; |
|
| 791 | 791 | } |
| 792 | 792 | } else { |
| 793 | - $qs[ $args[0] ] = $args[1]; |
|
| 793 | + $qs[$args[0]] = $args[1]; |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | - foreach ( $qs as $k => $v ) { |
|
| 797 | - if ( $v === false ) |
|
| 798 | - unset( $qs[$k] ); |
|
| 796 | + foreach ($qs as $k => $v) { |
|
| 797 | + if ($v === false) |
|
| 798 | + unset($qs[$k]); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | - $ret = build_query( $qs ); |
|
| 802 | - $ret = trim( $ret, '?' ); |
|
| 803 | - $ret = preg_replace( '#=(&|$)#', '$1', $ret ); |
|
| 804 | - $ret = $protocol . $base . $ret . $frag; |
|
| 805 | - $ret = rtrim( $ret, '?' ); |
|
| 801 | + $ret = build_query($qs); |
|
| 802 | + $ret = trim($ret, '?'); |
|
| 803 | + $ret = preg_replace('#=(&|$)#', '$1', $ret); |
|
| 804 | + $ret = $protocol.$base.$ret.$frag; |
|
| 805 | + $ret = rtrim($ret, '?'); |
|
| 806 | 806 | return $ret; |
| 807 | 807 | } |
| 808 | 808 | |
@@ -815,13 +815,13 @@ discard block |
||
| 815 | 815 | * @param bool|string $query Optional. When false uses the $_SERVER value. Default false. |
| 816 | 816 | * @return string New URL query string. |
| 817 | 817 | */ |
| 818 | -function remove_query_arg( $key, $query = false ) { |
|
| 819 | - if ( is_array( $key ) ) { // removing multiple keys |
|
| 820 | - foreach ( $key as $k ) |
|
| 821 | - $query = add_query_arg( $k, false, $query ); |
|
| 818 | +function remove_query_arg($key, $query = false) { |
|
| 819 | + if (is_array($key)) { // removing multiple keys |
|
| 820 | + foreach ($key as $k) |
|
| 821 | + $query = add_query_arg($k, false, $query); |
|
| 822 | 822 | return $query; |
| 823 | 823 | } |
| 824 | - return add_query_arg( $key, false, $query ); |
|
| 824 | + return add_query_arg($key, false, $query); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -832,12 +832,12 @@ discard block |
||
| 832 | 832 | * @param array $array Array to walk while sanitizing contents. |
| 833 | 833 | * @return array Sanitized $array. |
| 834 | 834 | */ |
| 835 | -function add_magic_quotes( $array ) { |
|
| 836 | - foreach ( (array) $array as $k => $v ) { |
|
| 837 | - if ( is_array( $v ) ) { |
|
| 838 | - $array[$k] = add_magic_quotes( $v ); |
|
| 835 | +function add_magic_quotes($array) { |
|
| 836 | + foreach ((array) $array as $k => $v) { |
|
| 837 | + if (is_array($v)) { |
|
| 838 | + $array[$k] = add_magic_quotes($v); |
|
| 839 | 839 | } else { |
| 840 | - $array[$k] = addslashes( $v ); |
|
| 840 | + $array[$k] = addslashes($v); |
|
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | return $array; |
@@ -853,21 +853,21 @@ discard block |
||
| 853 | 853 | * @param string $uri URI/URL of web page to retrieve. |
| 854 | 854 | * @return false|string HTTP content. False on failure. |
| 855 | 855 | */ |
| 856 | -function wp_remote_fopen( $uri ) { |
|
| 857 | - $parsed_url = @parse_url( $uri ); |
|
| 856 | +function wp_remote_fopen($uri) { |
|
| 857 | + $parsed_url = @parse_url($uri); |
|
| 858 | 858 | |
| 859 | - if ( !$parsed_url || !is_array( $parsed_url ) ) |
|
| 859 | + if ( ! $parsed_url || ! is_array($parsed_url)) |
|
| 860 | 860 | return false; |
| 861 | 861 | |
| 862 | 862 | $options = array(); |
| 863 | 863 | $options['timeout'] = 10; |
| 864 | 864 | |
| 865 | - $response = wp_safe_remote_get( $uri, $options ); |
|
| 865 | + $response = wp_safe_remote_get($uri, $options); |
|
| 866 | 866 | |
| 867 | - if ( is_wp_error( $response ) ) |
|
| 867 | + if (is_wp_error($response)) |
|
| 868 | 868 | return false; |
| 869 | 869 | |
| 870 | - return wp_remote_retrieve_body( $response ); |
|
| 870 | + return wp_remote_retrieve_body($response); |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
@@ -881,11 +881,11 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @param string|array $query_vars Default WP_Query arguments. |
| 883 | 883 | */ |
| 884 | -function wp( $query_vars = '' ) { |
|
| 884 | +function wp($query_vars = '') { |
|
| 885 | 885 | global $wp, $wp_query, $wp_the_query; |
| 886 | - $wp->main( $query_vars ); |
|
| 886 | + $wp->main($query_vars); |
|
| 887 | 887 | |
| 888 | - if ( !isset($wp_the_query) ) |
|
| 888 | + if ( ! isset($wp_the_query)) |
|
| 889 | 889 | $wp_the_query = $wp_query; |
| 890 | 890 | } |
| 891 | 891 | |
@@ -899,12 +899,12 @@ discard block |
||
| 899 | 899 | * @param int $code HTTP status code. |
| 900 | 900 | * @return string Empty string if not found, or description if found. |
| 901 | 901 | */ |
| 902 | -function get_status_header_desc( $code ) { |
|
| 902 | +function get_status_header_desc($code) { |
|
| 903 | 903 | global $wp_header_to_desc; |
| 904 | 904 | |
| 905 | - $code = absint( $code ); |
|
| 905 | + $code = absint($code); |
|
| 906 | 906 | |
| 907 | - if ( !isset( $wp_header_to_desc ) ) { |
|
| 907 | + if ( ! isset($wp_header_to_desc)) { |
|
| 908 | 908 | $wp_header_to_desc = array( |
| 909 | 909 | 100 => 'Continue', |
| 910 | 910 | 101 => 'Switching Protocols', |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | ); |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | - if ( isset( $wp_header_to_desc[$code] ) ) |
|
| 972 | + if (isset($wp_header_to_desc[$code])) |
|
| 973 | 973 | return $wp_header_to_desc[$code]; |
| 974 | 974 | else |
| 975 | 975 | return ''; |
@@ -984,17 +984,17 @@ discard block |
||
| 984 | 984 | * |
| 985 | 985 | * @param int $code HTTP status code. |
| 986 | 986 | */ |
| 987 | -function status_header( $code ) { |
|
| 988 | - $description = get_status_header_desc( $code ); |
|
| 987 | +function status_header($code) { |
|
| 988 | + $description = get_status_header_desc($code); |
|
| 989 | 989 | |
| 990 | - if ( empty( $description ) ) |
|
| 990 | + if (empty($description)) |
|
| 991 | 991 | return; |
| 992 | 992 | |
| 993 | 993 | $protocol = $_SERVER['SERVER_PROTOCOL']; |
| 994 | - if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) |
|
| 994 | + if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) |
|
| 995 | 995 | $protocol = 'HTTP/1.0'; |
| 996 | 996 | $status_header = "$protocol $code $description"; |
| 997 | - if ( function_exists( 'apply_filters' ) ) |
|
| 997 | + if (function_exists('apply_filters')) |
|
| 998 | 998 | |
| 999 | 999 | /** |
| 1000 | 1000 | * Filter an HTTP status header. |
@@ -1006,9 +1006,9 @@ discard block |
||
| 1006 | 1006 | * @param string $description Description for the status code. |
| 1007 | 1007 | * @param string $protocol Server protocol. |
| 1008 | 1008 | */ |
| 1009 | - $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); |
|
| 1009 | + $status_header = apply_filters('status_header', $status_header, $code, $description, $protocol); |
|
| 1010 | 1010 | |
| 1011 | - @header( $status_header, true, $code ); |
|
| 1011 | + @header($status_header, true, $code); |
|
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | /** |
@@ -1028,7 +1028,7 @@ discard block |
||
| 1028 | 1028 | 'Pragma' => 'no-cache', |
| 1029 | 1029 | ); |
| 1030 | 1030 | |
| 1031 | - if ( function_exists('apply_filters') ) { |
|
| 1031 | + if (function_exists('apply_filters')) { |
|
| 1032 | 1032 | /** |
| 1033 | 1033 | * Filter the cache-controlling headers. |
| 1034 | 1034 | * |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | * @type string $Pragma Pragma header. |
| 1045 | 1045 | * } |
| 1046 | 1046 | */ |
| 1047 | - $headers = (array) apply_filters( 'nocache_headers', $headers ); |
|
| 1047 | + $headers = (array) apply_filters('nocache_headers', $headers); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | $headers['Last-Modified'] = false; |
| 1050 | 1050 | return $headers; |
@@ -1064,23 +1064,23 @@ discard block |
||
| 1064 | 1064 | function nocache_headers() { |
| 1065 | 1065 | $headers = wp_get_nocache_headers(); |
| 1066 | 1066 | |
| 1067 | - unset( $headers['Last-Modified'] ); |
|
| 1067 | + unset($headers['Last-Modified']); |
|
| 1068 | 1068 | |
| 1069 | 1069 | // In PHP 5.3+, make sure we are not sending a Last-Modified header. |
| 1070 | - if ( function_exists( 'header_remove' ) ) { |
|
| 1071 | - @header_remove( 'Last-Modified' ); |
|
| 1070 | + if (function_exists('header_remove')) { |
|
| 1071 | + @header_remove('Last-Modified'); |
|
| 1072 | 1072 | } else { |
| 1073 | 1073 | // In PHP 5.2, send an empty Last-Modified header, but only as a |
| 1074 | 1074 | // last resort to override a header already sent. #WP23021 |
| 1075 | - foreach ( headers_list() as $header ) { |
|
| 1076 | - if ( 0 === stripos( $header, 'Last-Modified' ) ) { |
|
| 1075 | + foreach (headers_list() as $header) { |
|
| 1076 | + if (0 === stripos($header, 'Last-Modified')) { |
|
| 1077 | 1077 | $headers['Last-Modified'] = ''; |
| 1078 | 1078 | break; |
| 1079 | 1079 | } |
| 1080 | 1080 | } |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - foreach( $headers as $name => $field_value ) |
|
| 1083 | + foreach ($headers as $name => $field_value) |
|
| 1084 | 1084 | @header("{$name}: {$field_value}"); |
| 1085 | 1085 | } |
| 1086 | 1086 | |
@@ -1092,9 +1092,9 @@ discard block |
||
| 1092 | 1092 | function cache_javascript_headers() { |
| 1093 | 1093 | $expiresOffset = 10 * DAY_IN_SECONDS; |
| 1094 | 1094 | |
| 1095 | - header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) ); |
|
| 1096 | - header( "Vary: Accept-Encoding" ); // Handle proxies |
|
| 1097 | - header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" ); |
|
| 1095 | + header("Content-Type: text/javascript; charset=".get_bloginfo('charset')); |
|
| 1096 | + header("Vary: Accept-Encoding"); // Handle proxies |
|
| 1097 | + header("Expires: ".gmdate("D, d M Y H:i:s", time() + $expiresOffset)." GMT"); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | /** |
@@ -1121,8 +1121,8 @@ discard block |
||
| 1121 | 1121 | * @param string $yn Character string containing either 'y' (yes) or 'n' (no). |
| 1122 | 1122 | * @return bool True if yes, false on anything else. |
| 1123 | 1123 | */ |
| 1124 | -function bool_from_yn( $yn ) { |
|
| 1125 | - return ( strtolower( $yn ) == 'y' ); |
|
| 1124 | +function bool_from_yn($yn) { |
|
| 1125 | + return (strtolower($yn) == 'y'); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | /** |
@@ -1140,17 +1140,17 @@ discard block |
||
| 1140 | 1140 | function do_feed() { |
| 1141 | 1141 | global $wp_query; |
| 1142 | 1142 | |
| 1143 | - $feed = get_query_var( 'feed' ); |
|
| 1143 | + $feed = get_query_var('feed'); |
|
| 1144 | 1144 | |
| 1145 | 1145 | // Remove the pad, if present. |
| 1146 | - $feed = preg_replace( '/^_+/', '', $feed ); |
|
| 1146 | + $feed = preg_replace('/^_+/', '', $feed); |
|
| 1147 | 1147 | |
| 1148 | - if ( $feed == '' || $feed == 'feed' ) |
|
| 1148 | + if ($feed == '' || $feed == 'feed') |
|
| 1149 | 1149 | $feed = get_default_feed(); |
| 1150 | 1150 | |
| 1151 | - $hook = 'do_feed_' . $feed; |
|
| 1152 | - if ( ! has_action( $hook ) ) |
|
| 1153 | - wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) ); |
|
| 1151 | + $hook = 'do_feed_'.$feed; |
|
| 1152 | + if ( ! has_action($hook)) |
|
| 1153 | + wp_die(__('ERROR: This is not a valid feed template.'), '', array('response' => 404)); |
|
| 1154 | 1154 | |
| 1155 | 1155 | /** |
| 1156 | 1156 | * Fires once the given feed is loaded. |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | * |
| 1162 | 1162 | * @param bool $is_comment_feed Whether the feed is a comment feed. |
| 1163 | 1163 | */ |
| 1164 | - do_action( $hook, $wp_query->is_comment_feed ); |
|
| 1164 | + do_action($hook, $wp_query->is_comment_feed); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | * @see load_template() |
| 1173 | 1173 | */ |
| 1174 | 1174 | function do_feed_rdf() { |
| 1175 | - load_template( ABSPATH . WPINC . '/feed-rdf.php' ); |
|
| 1175 | + load_template(ABSPATH.WPINC.'/feed-rdf.php'); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | * @see load_template() |
| 1184 | 1184 | */ |
| 1185 | 1185 | function do_feed_rss() { |
| 1186 | - load_template( ABSPATH . WPINC . '/feed-rss.php' ); |
|
| 1186 | + load_template(ABSPATH.WPINC.'/feed-rss.php'); |
|
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | /** |
@@ -1195,11 +1195,11 @@ discard block |
||
| 1195 | 1195 | * |
| 1196 | 1196 | * @param bool $for_comments True for the comment feed, false for normal feed. |
| 1197 | 1197 | */ |
| 1198 | -function do_feed_rss2( $for_comments ) { |
|
| 1199 | - if ( $for_comments ) |
|
| 1200 | - load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); |
|
| 1198 | +function do_feed_rss2($for_comments) { |
|
| 1199 | + if ($for_comments) |
|
| 1200 | + load_template(ABSPATH.WPINC.'/feed-rss2-comments.php'); |
|
| 1201 | 1201 | else |
| 1202 | - load_template( ABSPATH . WPINC . '/feed-rss2.php' ); |
|
| 1202 | + load_template(ABSPATH.WPINC.'/feed-rss2.php'); |
|
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | /** |
@@ -1211,11 +1211,11 @@ discard block |
||
| 1211 | 1211 | * |
| 1212 | 1212 | * @param bool $for_comments True for the comment feed, false for normal feed. |
| 1213 | 1213 | */ |
| 1214 | -function do_feed_atom( $for_comments ) { |
|
| 1214 | +function do_feed_atom($for_comments) { |
|
| 1215 | 1215 | if ($for_comments) |
| 1216 | - load_template( ABSPATH . WPINC . '/feed-atom-comments.php'); |
|
| 1216 | + load_template(ABSPATH.WPINC.'/feed-atom-comments.php'); |
|
| 1217 | 1217 | else |
| 1218 | - load_template( ABSPATH . WPINC . '/feed-atom.php' ); |
|
| 1218 | + load_template(ABSPATH.WPINC.'/feed-atom.php'); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | /** |
@@ -1227,22 +1227,22 @@ discard block |
||
| 1227 | 1227 | * @since 2.1.0 |
| 1228 | 1228 | */ |
| 1229 | 1229 | function do_robots() { |
| 1230 | - header( 'Content-Type: text/plain; charset=utf-8' ); |
|
| 1230 | + header('Content-Type: text/plain; charset=utf-8'); |
|
| 1231 | 1231 | |
| 1232 | 1232 | /** |
| 1233 | 1233 | * Fires when displaying the robots.txt file. |
| 1234 | 1234 | * |
| 1235 | 1235 | * @since 2.1.0 |
| 1236 | 1236 | */ |
| 1237 | - do_action( 'do_robotstxt' ); |
|
| 1237 | + do_action('do_robotstxt'); |
|
| 1238 | 1238 | |
| 1239 | 1239 | $output = "User-agent: *\n"; |
| 1240 | - $public = get_option( 'blog_public' ); |
|
| 1241 | - if ( '0' == $public ) { |
|
| 1240 | + $public = get_option('blog_public'); |
|
| 1241 | + if ('0' == $public) { |
|
| 1242 | 1242 | $output .= "Disallow: /\n"; |
| 1243 | 1243 | } else { |
| 1244 | - $site_url = parse_url( site_url() ); |
|
| 1245 | - $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : ''; |
|
| 1244 | + $site_url = parse_url(site_url()); |
|
| 1245 | + $path = ( ! empty($site_url['path'])) ? $site_url['path'] : ''; |
|
| 1246 | 1246 | $output .= "Disallow: $path/wp-admin/\n"; |
| 1247 | 1247 | } |
| 1248 | 1248 | |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | * @param string $output Robots.txt output. |
| 1255 | 1255 | * @param bool $public Whether the site is considered "public". |
| 1256 | 1256 | */ |
| 1257 | - echo apply_filters( 'robots_txt', $output, $public ); |
|
| 1257 | + echo apply_filters('robots_txt', $output, $public); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | /** |
@@ -1279,28 +1279,28 @@ discard block |
||
| 1279 | 1279 | * Check cache first. If options table goes away and we have true |
| 1280 | 1280 | * cached, oh well. |
| 1281 | 1281 | */ |
| 1282 | - if ( wp_cache_get( 'is_blog_installed' ) ) |
|
| 1282 | + if (wp_cache_get('is_blog_installed')) |
|
| 1283 | 1283 | return true; |
| 1284 | 1284 | |
| 1285 | 1285 | $suppress = $wpdb->suppress_errors(); |
| 1286 | - if ( ! defined( 'WP_INSTALLING' ) ) { |
|
| 1286 | + if ( ! defined('WP_INSTALLING')) { |
|
| 1287 | 1287 | $alloptions = wp_load_alloptions(); |
| 1288 | 1288 | } |
| 1289 | 1289 | // If siteurl is not set to autoload, check it specifically |
| 1290 | - if ( !isset( $alloptions['siteurl'] ) ) |
|
| 1291 | - $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); |
|
| 1290 | + if ( ! isset($alloptions['siteurl'])) |
|
| 1291 | + $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'"); |
|
| 1292 | 1292 | else |
| 1293 | 1293 | $installed = $alloptions['siteurl']; |
| 1294 | - $wpdb->suppress_errors( $suppress ); |
|
| 1294 | + $wpdb->suppress_errors($suppress); |
|
| 1295 | 1295 | |
| 1296 | - $installed = !empty( $installed ); |
|
| 1297 | - wp_cache_set( 'is_blog_installed', $installed ); |
|
| 1296 | + $installed = ! empty($installed); |
|
| 1297 | + wp_cache_set('is_blog_installed', $installed); |
|
| 1298 | 1298 | |
| 1299 | - if ( $installed ) |
|
| 1299 | + if ($installed) |
|
| 1300 | 1300 | return true; |
| 1301 | 1301 | |
| 1302 | 1302 | // If visiting repair.php, return true and let it take over. |
| 1303 | - if ( defined( 'WP_REPAIRING' ) ) |
|
| 1303 | + if (defined('WP_REPAIRING')) |
|
| 1304 | 1304 | return true; |
| 1305 | 1305 | |
| 1306 | 1306 | $suppress = $wpdb->suppress_errors(); |
@@ -1311,14 +1311,14 @@ discard block |
||
| 1311 | 1311 | * options table could not be accessed. |
| 1312 | 1312 | */ |
| 1313 | 1313 | $wp_tables = $wpdb->tables(); |
| 1314 | - foreach ( $wp_tables as $table ) { |
|
| 1314 | + foreach ($wp_tables as $table) { |
|
| 1315 | 1315 | // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install. |
| 1316 | - if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) |
|
| 1316 | + if (defined('CUSTOM_USER_TABLE') && CUSTOM_USER_TABLE == $table) |
|
| 1317 | 1317 | continue; |
| 1318 | - if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) |
|
| 1318 | + if (defined('CUSTOM_USER_META_TABLE') && CUSTOM_USER_META_TABLE == $table) |
|
| 1319 | 1319 | continue; |
| 1320 | 1320 | |
| 1321 | - if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) |
|
| 1321 | + if ( ! $wpdb->get_results("DESCRIBE $table;")) |
|
| 1322 | 1322 | continue; |
| 1323 | 1323 | |
| 1324 | 1324 | // One or more tables exist. We are insane. |
@@ -1326,13 +1326,13 @@ discard block |
||
| 1326 | 1326 | wp_load_translations_early(); |
| 1327 | 1327 | |
| 1328 | 1328 | // Die with a DB error. |
| 1329 | - $wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.' ), 'maint/repair.php?referrer=is_blog_installed' ); |
|
| 1329 | + $wpdb->error = sprintf(__('One or more database tables are unavailable. The database may need to be <a href="%s">repaired</a>.'), 'maint/repair.php?referrer=is_blog_installed'); |
|
| 1330 | 1330 | dead_db(); |
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | - $wpdb->suppress_errors( $suppress ); |
|
| 1333 | + $wpdb->suppress_errors($suppress); |
|
| 1334 | 1334 | |
| 1335 | - wp_cache_set( 'is_blog_installed', false ); |
|
| 1335 | + wp_cache_set('is_blog_installed', false); |
|
| 1336 | 1336 | |
| 1337 | 1337 | return false; |
| 1338 | 1338 | } |
@@ -1347,9 +1347,9 @@ discard block |
||
| 1347 | 1347 | * @param string $name Optional. Nonce name. Default '_wpnonce'. |
| 1348 | 1348 | * @return string Escaped URL with nonce action added. |
| 1349 | 1349 | */ |
| 1350 | -function wp_nonce_url( $actionurl, $action = -1, $name = '_wpnonce' ) { |
|
| 1351 | - $actionurl = str_replace( '&', '&', $actionurl ); |
|
| 1352 | - return esc_html( add_query_arg( $name, wp_create_nonce( $action ), $actionurl ) ); |
|
| 1350 | +function wp_nonce_url($actionurl, $action = -1, $name = '_wpnonce') { |
|
| 1351 | + $actionurl = str_replace('&', '&', $actionurl); |
|
| 1352 | + return esc_html(add_query_arg($name, wp_create_nonce($action), $actionurl)); |
|
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | 1355 | /** |
@@ -1378,14 +1378,14 @@ discard block |
||
| 1378 | 1378 | * @param bool $echo Optional. Whether to display or return hidden form field. Default true. |
| 1379 | 1379 | * @return string Nonce field HTML markup. |
| 1380 | 1380 | */ |
| 1381 | -function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) { |
|
| 1382 | - $name = esc_attr( $name ); |
|
| 1383 | - $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; |
|
| 1381 | +function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true, $echo = true) { |
|
| 1382 | + $name = esc_attr($name); |
|
| 1383 | + $nonce_field = '<input type="hidden" id="'.$name.'" name="'.$name.'" value="'.wp_create_nonce($action).'" />'; |
|
| 1384 | 1384 | |
| 1385 | - if ( $referer ) |
|
| 1386 | - $nonce_field .= wp_referer_field( false ); |
|
| 1385 | + if ($referer) |
|
| 1386 | + $nonce_field .= wp_referer_field(false); |
|
| 1387 | 1387 | |
| 1388 | - if ( $echo ) |
|
| 1388 | + if ($echo) |
|
| 1389 | 1389 | echo $nonce_field; |
| 1390 | 1390 | |
| 1391 | 1391 | return $nonce_field; |
@@ -1402,10 +1402,10 @@ discard block |
||
| 1402 | 1402 | * @param bool $echo Optional. Whether to echo or return the referer field. Default true. |
| 1403 | 1403 | * @return string Referer field HTML markup. |
| 1404 | 1404 | */ |
| 1405 | -function wp_referer_field( $echo = true ) { |
|
| 1406 | - $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; |
|
| 1405 | +function wp_referer_field($echo = true) { |
|
| 1406 | + $referer_field = '<input type="hidden" name="_wp_http_referer" value="'.esc_attr(wp_unslash($_SERVER['REQUEST_URI'])).'" />'; |
|
| 1407 | 1407 | |
| 1408 | - if ( $echo ) |
|
| 1408 | + if ($echo) |
|
| 1409 | 1409 | echo $referer_field; |
| 1410 | 1410 | return $referer_field; |
| 1411 | 1411 | } |
@@ -1424,12 +1424,12 @@ discard block |
||
| 1424 | 1424 | * Default 'current'. |
| 1425 | 1425 | * @return string Original referer field. |
| 1426 | 1426 | */ |
| 1427 | -function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) { |
|
| 1428 | - if ( ! $ref = wp_get_original_referer() ) { |
|
| 1429 | - $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); |
|
| 1427 | +function wp_original_referer_field($echo = true, $jump_back_to = 'current') { |
|
| 1428 | + if ( ! $ref = wp_get_original_referer()) { |
|
| 1429 | + $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']); |
|
| 1430 | 1430 | } |
| 1431 | - $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; |
|
| 1432 | - if ( $echo ) |
|
| 1431 | + $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="'.esc_attr($ref).'" />'; |
|
| 1432 | + if ($echo) |
|
| 1433 | 1433 | echo $orig_referer_field; |
| 1434 | 1434 | return $orig_referer_field; |
| 1435 | 1435 | } |
@@ -1444,16 +1444,16 @@ discard block |
||
| 1444 | 1444 | * @return false|string False on failure. Referer URL on success. |
| 1445 | 1445 | */ |
| 1446 | 1446 | function wp_get_referer() { |
| 1447 | - if ( ! function_exists( 'wp_validate_redirect' ) ) |
|
| 1447 | + if ( ! function_exists('wp_validate_redirect')) |
|
| 1448 | 1448 | return false; |
| 1449 | 1449 | $ref = false; |
| 1450 | - if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) |
|
| 1451 | - $ref = wp_unslash( $_REQUEST['_wp_http_referer'] ); |
|
| 1452 | - elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) |
|
| 1453 | - $ref = wp_unslash( $_SERVER['HTTP_REFERER'] ); |
|
| 1450 | + if ( ! empty($_REQUEST['_wp_http_referer'])) |
|
| 1451 | + $ref = wp_unslash($_REQUEST['_wp_http_referer']); |
|
| 1452 | + elseif ( ! empty($_SERVER['HTTP_REFERER'])) |
|
| 1453 | + $ref = wp_unslash($_SERVER['HTTP_REFERER']); |
|
| 1454 | 1454 | |
| 1455 | - if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) ) |
|
| 1456 | - return wp_validate_redirect( $ref, false ); |
|
| 1455 | + if ($ref && $ref !== wp_unslash($_SERVER['REQUEST_URI'])) |
|
| 1456 | + return wp_validate_redirect($ref, false); |
|
| 1457 | 1457 | return false; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
@@ -1465,8 +1465,8 @@ discard block |
||
| 1465 | 1465 | * @return string|false False if no original referer or original referer if set. |
| 1466 | 1466 | */ |
| 1467 | 1467 | function wp_get_original_referer() { |
| 1468 | - if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) |
|
| 1469 | - return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); |
|
| 1468 | + if ( ! empty($_REQUEST['_wp_original_http_referer']) && function_exists('wp_validate_redirect')) |
|
| 1469 | + return wp_validate_redirect(wp_unslash($_REQUEST['_wp_original_http_referer']), false); |
|
| 1470 | 1470 | return false; |
| 1471 | 1471 | } |
| 1472 | 1472 | |
@@ -1480,20 +1480,20 @@ discard block |
||
| 1480 | 1480 | * @param string $target Full path to attempt to create. |
| 1481 | 1481 | * @return bool Whether the path was created. True if path already exists. |
| 1482 | 1482 | */ |
| 1483 | -function wp_mkdir_p( $target ) { |
|
| 1483 | +function wp_mkdir_p($target) { |
|
| 1484 | 1484 | $wrapper = null; |
| 1485 | 1485 | |
| 1486 | 1486 | // Strip the protocol. |
| 1487 | - if ( wp_is_stream( $target ) ) { |
|
| 1488 | - list( $wrapper, $target ) = explode( '://', $target, 2 ); |
|
| 1487 | + if (wp_is_stream($target)) { |
|
| 1488 | + list($wrapper, $target) = explode('://', $target, 2); |
|
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | 1491 | // From php.net/mkdir user contributed notes. |
| 1492 | - $target = str_replace( '//', '/', $target ); |
|
| 1492 | + $target = str_replace('//', '/', $target); |
|
| 1493 | 1493 | |
| 1494 | 1494 | // Put the wrapper back on the target. |
| 1495 | - if ( $wrapper !== null ) { |
|
| 1496 | - $target = $wrapper . '://' . $target; |
|
| 1495 | + if ($wrapper !== null) { |
|
| 1496 | + $target = $wrapper.'://'.$target; |
|
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | /* |
@@ -1501,35 +1501,35 @@ discard block |
||
| 1501 | 1501 | * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. |
| 1502 | 1502 | */ |
| 1503 | 1503 | $target = rtrim($target, '/'); |
| 1504 | - if ( empty($target) ) |
|
| 1504 | + if (empty($target)) |
|
| 1505 | 1505 | $target = '/'; |
| 1506 | 1506 | |
| 1507 | - if ( file_exists( $target ) ) |
|
| 1508 | - return @is_dir( $target ); |
|
| 1507 | + if (file_exists($target)) |
|
| 1508 | + return @is_dir($target); |
|
| 1509 | 1509 | |
| 1510 | 1510 | // We need to find the permissions of the parent folder that exists and inherit that. |
| 1511 | - $target_parent = dirname( $target ); |
|
| 1512 | - while ( '.' != $target_parent && ! is_dir( $target_parent ) ) { |
|
| 1513 | - $target_parent = dirname( $target_parent ); |
|
| 1511 | + $target_parent = dirname($target); |
|
| 1512 | + while ('.' != $target_parent && ! is_dir($target_parent)) { |
|
| 1513 | + $target_parent = dirname($target_parent); |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | // Get the permission bits. |
| 1517 | - if ( $stat = @stat( $target_parent ) ) { |
|
| 1517 | + if ($stat = @stat($target_parent)) { |
|
| 1518 | 1518 | $dir_perms = $stat['mode'] & 0007777; |
| 1519 | 1519 | } else { |
| 1520 | 1520 | $dir_perms = 0777; |
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | - if ( @mkdir( $target, $dir_perms, true ) ) { |
|
| 1523 | + if (@mkdir($target, $dir_perms, true)) { |
|
| 1524 | 1524 | |
| 1525 | 1525 | /* |
| 1526 | 1526 | * If a umask is set that modifies $dir_perms, we'll have to re-set |
| 1527 | 1527 | * the $dir_perms correctly with chmod() |
| 1528 | 1528 | */ |
| 1529 | - if ( $dir_perms != ( $dir_perms & ~umask() ) ) { |
|
| 1530 | - $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); |
|
| 1531 | - for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) { |
|
| 1532 | - @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms ); |
|
| 1529 | + if ($dir_perms != ($dir_perms & ~umask())) { |
|
| 1530 | + $folder_parts = explode('/', substr($target, strlen($target_parent) + 1)); |
|
| 1531 | + for ($i = 1, $c = count($folder_parts); $i <= $c; $i++) { |
|
| 1532 | + @chmod($target_parent.'/'.implode('/', array_slice($folder_parts, 0, $i)), $dir_perms); |
|
| 1533 | 1533 | } |
| 1534 | 1534 | } |
| 1535 | 1535 | |
@@ -1549,23 +1549,23 @@ discard block |
||
| 1549 | 1549 | * @param string $path File path. |
| 1550 | 1550 | * @return bool True if path is absolute, false is not absolute. |
| 1551 | 1551 | */ |
| 1552 | -function path_is_absolute( $path ) { |
|
| 1552 | +function path_is_absolute($path) { |
|
| 1553 | 1553 | /* |
| 1554 | 1554 | * This is definitive if true but fails if $path does not exist or contains |
| 1555 | 1555 | * a symbolic link. |
| 1556 | 1556 | */ |
| 1557 | - if ( realpath($path) == $path ) |
|
| 1557 | + if (realpath($path) == $path) |
|
| 1558 | 1558 | return true; |
| 1559 | 1559 | |
| 1560 | - if ( strlen($path) == 0 || $path[0] == '.' ) |
|
| 1560 | + if (strlen($path) == 0 || $path[0] == '.') |
|
| 1561 | 1561 | return false; |
| 1562 | 1562 | |
| 1563 | 1563 | // Windows allows absolute paths like this. |
| 1564 | - if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) |
|
| 1564 | + if (preg_match('#^[a-zA-Z]:\\\\#', $path)) |
|
| 1565 | 1565 | return true; |
| 1566 | 1566 | |
| 1567 | 1567 | // A path starting with / or \ is absolute; anything else is relative. |
| 1568 | - return ( $path[0] == '/' || $path[0] == '\\' ); |
|
| 1568 | + return ($path[0] == '/' || $path[0] == '\\'); |
|
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | 1571 | /** |
@@ -1580,11 +1580,11 @@ discard block |
||
| 1580 | 1580 | * @param string $path Path relative to $base. |
| 1581 | 1581 | * @return string The path with the base or absolute path. |
| 1582 | 1582 | */ |
| 1583 | -function path_join( $base, $path ) { |
|
| 1584 | - if ( path_is_absolute($path) ) |
|
| 1583 | +function path_join($base, $path) { |
|
| 1584 | + if (path_is_absolute($path)) |
|
| 1585 | 1585 | return $path; |
| 1586 | 1586 | |
| 1587 | - return rtrim($base, '/') . '/' . ltrim($path, '/'); |
|
| 1587 | + return rtrim($base, '/').'/'.ltrim($path, '/'); |
|
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | /** |
@@ -1598,9 +1598,9 @@ discard block |
||
| 1598 | 1598 | * @param string $path Path to normalize. |
| 1599 | 1599 | * @return string Normalized path. |
| 1600 | 1600 | */ |
| 1601 | -function wp_normalize_path( $path ) { |
|
| 1602 | - $path = str_replace( '\\', '/', $path ); |
|
| 1603 | - $path = preg_replace( '|/+|','/', $path ); |
|
| 1601 | +function wp_normalize_path($path) { |
|
| 1602 | + $path = str_replace('\\', '/', $path); |
|
| 1603 | + $path = preg_replace('|/+|', '/', $path); |
|
| 1604 | 1604 | return $path; |
| 1605 | 1605 | } |
| 1606 | 1606 | |
@@ -1622,24 +1622,24 @@ discard block |
||
| 1622 | 1622 | */ |
| 1623 | 1623 | function get_temp_dir() { |
| 1624 | 1624 | static $temp = ''; |
| 1625 | - if ( defined('WP_TEMP_DIR') ) |
|
| 1625 | + if (defined('WP_TEMP_DIR')) |
|
| 1626 | 1626 | return trailingslashit(WP_TEMP_DIR); |
| 1627 | 1627 | |
| 1628 | - if ( $temp ) |
|
| 1629 | - return trailingslashit( $temp ); |
|
| 1628 | + if ($temp) |
|
| 1629 | + return trailingslashit($temp); |
|
| 1630 | 1630 | |
| 1631 | - if ( function_exists('sys_get_temp_dir') ) { |
|
| 1631 | + if (function_exists('sys_get_temp_dir')) { |
|
| 1632 | 1632 | $temp = sys_get_temp_dir(); |
| 1633 | - if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1634 | - return trailingslashit( $temp ); |
|
| 1633 | + if (@is_dir($temp) && wp_is_writable($temp)) |
|
| 1634 | + return trailingslashit($temp); |
|
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | $temp = ini_get('upload_tmp_dir'); |
| 1638 | - if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1639 | - return trailingslashit( $temp ); |
|
| 1638 | + if (@is_dir($temp) && wp_is_writable($temp)) |
|
| 1639 | + return trailingslashit($temp); |
|
| 1640 | 1640 | |
| 1641 | - $temp = WP_CONTENT_DIR . '/'; |
|
| 1642 | - if ( is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1641 | + $temp = WP_CONTENT_DIR.'/'; |
|
| 1642 | + if (is_dir($temp) && wp_is_writable($temp)) |
|
| 1643 | 1643 | return $temp; |
| 1644 | 1644 | |
| 1645 | 1645 | return '/tmp/'; |
@@ -1658,11 +1658,11 @@ discard block |
||
| 1658 | 1658 | * @param string $path Path to check for write-ability. |
| 1659 | 1659 | * @return bool Whether the path is writable. |
| 1660 | 1660 | */ |
| 1661 | -function wp_is_writable( $path ) { |
|
| 1662 | - if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) |
|
| 1663 | - return win_is_writable( $path ); |
|
| 1661 | +function wp_is_writable($path) { |
|
| 1662 | + if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) |
|
| 1663 | + return win_is_writable($path); |
|
| 1664 | 1664 | else |
| 1665 | - return @is_writable( $path ); |
|
| 1665 | + return @is_writable($path); |
|
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | 1668 | /** |
@@ -1681,21 +1681,21 @@ discard block |
||
| 1681 | 1681 | * @param string $path Windows path to check for write-ability. |
| 1682 | 1682 | * @return bool Whether the path is writable. |
| 1683 | 1683 | */ |
| 1684 | -function win_is_writable( $path ) { |
|
| 1684 | +function win_is_writable($path) { |
|
| 1685 | 1685 | |
| 1686 | - if ( $path[strlen( $path ) - 1] == '/' ) { // if it looks like a directory, check a random file within the directory |
|
| 1687 | - return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); |
|
| 1688 | - } elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory |
|
| 1689 | - return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); |
|
| 1686 | + if ($path[strlen($path) - 1] == '/') { // if it looks like a directory, check a random file within the directory |
|
| 1687 | + return win_is_writable($path.uniqid(mt_rand()).'.tmp'); |
|
| 1688 | + } elseif (is_dir($path)) { // If it's a directory (and not a file) check a random file within the directory |
|
| 1689 | + return win_is_writable($path.'/'.uniqid(mt_rand()).'.tmp'); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | // check tmp file for read/write capabilities |
| 1692 | - $should_delete_tmp_file = !file_exists( $path ); |
|
| 1693 | - $f = @fopen( $path, 'a' ); |
|
| 1694 | - if ( $f === false ) |
|
| 1692 | + $should_delete_tmp_file = ! file_exists($path); |
|
| 1693 | + $f = @fopen($path, 'a'); |
|
| 1694 | + if ($f === false) |
|
| 1695 | 1695 | return false; |
| 1696 | - fclose( $f ); |
|
| 1697 | - if ( $should_delete_tmp_file ) |
|
| 1698 | - unlink( $path ); |
|
| 1696 | + fclose($f); |
|
| 1697 | + if ($should_delete_tmp_file) |
|
| 1698 | + unlink($path); |
|
| 1699 | 1699 | return true; |
| 1700 | 1700 | } |
| 1701 | 1701 | |
@@ -1731,39 +1731,39 @@ discard block |
||
| 1731 | 1731 | * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
| 1732 | 1732 | * @return array See above for description. |
| 1733 | 1733 | */ |
| 1734 | -function wp_upload_dir( $time = null ) { |
|
| 1735 | - $siteurl = get_option( 'siteurl' ); |
|
| 1736 | - $upload_path = trim( get_option( 'upload_path' ) ); |
|
| 1734 | +function wp_upload_dir($time = null) { |
|
| 1735 | + $siteurl = get_option('siteurl'); |
|
| 1736 | + $upload_path = trim(get_option('upload_path')); |
|
| 1737 | 1737 | |
| 1738 | - if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) { |
|
| 1739 | - $dir = WP_CONTENT_DIR . '/uploads'; |
|
| 1740 | - } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { |
|
| 1738 | + if (empty($upload_path) || 'wp-content/uploads' == $upload_path) { |
|
| 1739 | + $dir = WP_CONTENT_DIR.'/uploads'; |
|
| 1740 | + } elseif (0 !== strpos($upload_path, ABSPATH)) { |
|
| 1741 | 1741 | // $dir is absolute, $upload_path is (maybe) relative to ABSPATH |
| 1742 | - $dir = path_join( ABSPATH, $upload_path ); |
|
| 1742 | + $dir = path_join(ABSPATH, $upload_path); |
|
| 1743 | 1743 | } else { |
| 1744 | 1744 | $dir = $upload_path; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | - if ( !$url = get_option( 'upload_url_path' ) ) { |
|
| 1748 | - if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) |
|
| 1749 | - $url = WP_CONTENT_URL . '/uploads'; |
|
| 1747 | + if ( ! $url = get_option('upload_url_path')) { |
|
| 1748 | + if (empty($upload_path) || ('wp-content/uploads' == $upload_path) || ($upload_path == $dir)) |
|
| 1749 | + $url = WP_CONTENT_URL.'/uploads'; |
|
| 1750 | 1750 | else |
| 1751 | - $url = trailingslashit( $siteurl ) . $upload_path; |
|
| 1751 | + $url = trailingslashit($siteurl).$upload_path; |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | /* |
| 1755 | 1755 | * Honor the value of UPLOADS. This happens as long as ms-files rewriting is disabled. |
| 1756 | 1756 | * We also sometimes obey UPLOADS when rewriting is enabled -- see the next block. |
| 1757 | 1757 | */ |
| 1758 | - if ( defined( 'UPLOADS' ) && ! ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) ) { |
|
| 1759 | - $dir = ABSPATH . UPLOADS; |
|
| 1760 | - $url = trailingslashit( $siteurl ) . UPLOADS; |
|
| 1758 | + if (defined('UPLOADS') && ! (is_multisite() && get_site_option('ms_files_rewriting'))) { |
|
| 1759 | + $dir = ABSPATH.UPLOADS; |
|
| 1760 | + $url = trailingslashit($siteurl).UPLOADS; |
|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | // If multisite (and if not the main site in a post-MU network) |
| 1764 | - if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { |
|
| 1764 | + if (is_multisite() && ! (is_main_network() && is_main_site() && defined('MULTISITE'))) { |
|
| 1765 | 1765 | |
| 1766 | - if ( ! get_site_option( 'ms_files_rewriting' ) ) { |
|
| 1766 | + if ( ! get_site_option('ms_files_rewriting')) { |
|
| 1767 | 1767 | /* |
| 1768 | 1768 | * If ms-files rewriting is disabled (networks created post-3.5), it is fairly |
| 1769 | 1769 | * straightforward: Append sites/%d if we're not on the main site (for post-MU |
@@ -1773,15 +1773,15 @@ discard block |
||
| 1773 | 1773 | * had wp-content/uploads for the main site.) |
| 1774 | 1774 | */ |
| 1775 | 1775 | |
| 1776 | - if ( defined( 'MULTISITE' ) ) |
|
| 1777 | - $ms_dir = '/sites/' . get_current_blog_id(); |
|
| 1776 | + if (defined('MULTISITE')) |
|
| 1777 | + $ms_dir = '/sites/'.get_current_blog_id(); |
|
| 1778 | 1778 | else |
| 1779 | - $ms_dir = '/' . get_current_blog_id(); |
|
| 1779 | + $ms_dir = '/'.get_current_blog_id(); |
|
| 1780 | 1780 | |
| 1781 | 1781 | $dir .= $ms_dir; |
| 1782 | 1782 | $url .= $ms_dir; |
| 1783 | 1783 | |
| 1784 | - } elseif ( defined( 'UPLOADS' ) && ! ms_is_switched() ) { |
|
| 1784 | + } elseif (defined('UPLOADS') && ! ms_is_switched()) { |
|
| 1785 | 1785 | /* |
| 1786 | 1786 | * Handle the old-form ms-files.php rewriting if the network still has that enabled. |
| 1787 | 1787 | * When ms-files rewriting is enabled, then we only listen to UPLOADS when: |
@@ -1796,11 +1796,11 @@ discard block |
||
| 1796 | 1796 | * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) |
| 1797 | 1797 | */ |
| 1798 | 1798 | |
| 1799 | - if ( defined( 'BLOGUPLOADDIR' ) ) |
|
| 1800 | - $dir = untrailingslashit( BLOGUPLOADDIR ); |
|
| 1799 | + if (defined('BLOGUPLOADDIR')) |
|
| 1800 | + $dir = untrailingslashit(BLOGUPLOADDIR); |
|
| 1801 | 1801 | else |
| 1802 | - $dir = ABSPATH . UPLOADS; |
|
| 1803 | - $url = trailingslashit( $siteurl ) . 'files'; |
|
| 1802 | + $dir = ABSPATH.UPLOADS; |
|
| 1803 | + $url = trailingslashit($siteurl).'files'; |
|
| 1804 | 1804 | } |
| 1805 | 1805 | } |
| 1806 | 1806 | |
@@ -1808,12 +1808,12 @@ discard block |
||
| 1808 | 1808 | $baseurl = $url; |
| 1809 | 1809 | |
| 1810 | 1810 | $subdir = ''; |
| 1811 | - if ( get_option( 'uploads_use_yearmonth_folders' ) ) { |
|
| 1811 | + if (get_option('uploads_use_yearmonth_folders')) { |
|
| 1812 | 1812 | // Generate the yearly and monthly dirs |
| 1813 | - if ( !$time ) |
|
| 1814 | - $time = current_time( 'mysql' ); |
|
| 1815 | - $y = substr( $time, 0, 4 ); |
|
| 1816 | - $m = substr( $time, 5, 2 ); |
|
| 1813 | + if ( ! $time) |
|
| 1814 | + $time = current_time('mysql'); |
|
| 1815 | + $y = substr($time, 0, 4); |
|
| 1816 | + $m = substr($time, 5, 2); |
|
| 1817 | 1817 | $subdir = "/$y/$m"; |
| 1818 | 1818 | } |
| 1819 | 1819 | |
@@ -1828,7 +1828,7 @@ discard block |
||
| 1828 | 1828 | * @param array $uploads Array of upload directory data with keys of 'path', |
| 1829 | 1829 | * 'url', 'subdir, 'basedir', and 'error'. |
| 1830 | 1830 | */ |
| 1831 | - $uploads = apply_filters( 'upload_dir', |
|
| 1831 | + $uploads = apply_filters('upload_dir', |
|
| 1832 | 1832 | array( |
| 1833 | 1833 | 'path' => $dir, |
| 1834 | 1834 | 'url' => $url, |
@@ -1836,16 +1836,16 @@ discard block |
||
| 1836 | 1836 | 'basedir' => $basedir, |
| 1837 | 1837 | 'baseurl' => $baseurl, |
| 1838 | 1838 | 'error' => false, |
| 1839 | - ) ); |
|
| 1839 | + )); |
|
| 1840 | 1840 | |
| 1841 | 1841 | // Make sure we have an uploads directory. |
| 1842 | - if ( ! wp_mkdir_p( $uploads['path'] ) ) { |
|
| 1843 | - if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) |
|
| 1844 | - $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1842 | + if ( ! wp_mkdir_p($uploads['path'])) { |
|
| 1843 | + if (0 === strpos($uploads['basedir'], ABSPATH)) |
|
| 1844 | + $error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir']; |
|
| 1845 | 1845 | else |
| 1846 | - $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1846 | + $error_path = basename($uploads['basedir']).$uploads['subdir']; |
|
| 1847 | 1847 | |
| 1848 | - $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); |
|
| 1848 | + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $error_path); |
|
| 1849 | 1849 | $uploads['error'] = $message; |
| 1850 | 1850 | } |
| 1851 | 1851 | |
@@ -1869,48 +1869,48 @@ discard block |
||
| 1869 | 1869 | * @param callback $unique_filename_callback Callback. Default null. |
| 1870 | 1870 | * @return string New filename, if given wasn't unique. |
| 1871 | 1871 | */ |
| 1872 | -function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { |
|
| 1872 | +function wp_unique_filename($dir, $filename, $unique_filename_callback = null) { |
|
| 1873 | 1873 | // Sanitize the file name before we begin processing. |
| 1874 | 1874 | $filename = sanitize_file_name($filename); |
| 1875 | 1875 | |
| 1876 | 1876 | // Separate the filename into a name and extension. |
| 1877 | 1877 | $info = pathinfo($filename); |
| 1878 | - $ext = !empty($info['extension']) ? '.' . $info['extension'] : ''; |
|
| 1878 | + $ext = ! empty($info['extension']) ? '.'.$info['extension'] : ''; |
|
| 1879 | 1879 | $name = basename($filename, $ext); |
| 1880 | 1880 | |
| 1881 | 1881 | // Edge case: if file is named '.ext', treat as an empty name. |
| 1882 | - if ( $name === $ext ) |
|
| 1882 | + if ($name === $ext) |
|
| 1883 | 1883 | $name = ''; |
| 1884 | 1884 | |
| 1885 | 1885 | /* |
| 1886 | 1886 | * Increment the file number until we have a unique file to save in $dir. |
| 1887 | 1887 | * Use callback if supplied. |
| 1888 | 1888 | */ |
| 1889 | - if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { |
|
| 1890 | - $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext ); |
|
| 1889 | + if ($unique_filename_callback && is_callable($unique_filename_callback)) { |
|
| 1890 | + $filename = call_user_func($unique_filename_callback, $dir, $name, $ext); |
|
| 1891 | 1891 | } else { |
| 1892 | 1892 | $number = ''; |
| 1893 | 1893 | |
| 1894 | 1894 | // Change '.ext' to lower case. |
| 1895 | - if ( $ext && strtolower($ext) != $ext ) { |
|
| 1895 | + if ($ext && strtolower($ext) != $ext) { |
|
| 1896 | 1896 | $ext2 = strtolower($ext); |
| 1897 | - $filename2 = preg_replace( '|' . preg_quote($ext) . '$|', $ext2, $filename ); |
|
| 1897 | + $filename2 = preg_replace('|'.preg_quote($ext).'$|', $ext2, $filename); |
|
| 1898 | 1898 | |
| 1899 | 1899 | // Check for both lower and upper case extension or image sub-sizes may be overwritten. |
| 1900 | - while ( file_exists($dir . "/$filename") || file_exists($dir . "/$filename2") ) { |
|
| 1900 | + while (file_exists($dir."/$filename") || file_exists($dir."/$filename2")) { |
|
| 1901 | 1901 | $new_number = $number + 1; |
| 1902 | - $filename = str_replace( "$number$ext", "$new_number$ext", $filename ); |
|
| 1903 | - $filename2 = str_replace( "$number$ext2", "$new_number$ext2", $filename2 ); |
|
| 1902 | + $filename = str_replace("$number$ext", "$new_number$ext", $filename); |
|
| 1903 | + $filename2 = str_replace("$number$ext2", "$new_number$ext2", $filename2); |
|
| 1904 | 1904 | $number = $new_number; |
| 1905 | 1905 | } |
| 1906 | 1906 | return $filename2; |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - while ( file_exists( $dir . "/$filename" ) ) { |
|
| 1910 | - if ( '' == "$number$ext" ) |
|
| 1911 | - $filename = $filename . ++$number . $ext; |
|
| 1909 | + while (file_exists($dir."/$filename")) { |
|
| 1910 | + if ('' == "$number$ext") |
|
| 1911 | + $filename = $filename.++$number.$ext; |
|
| 1912 | 1912 | else |
| 1913 | - $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); |
|
| 1913 | + $filename = str_replace("$number$ext", ++$number.$ext, $filename); |
|
| 1914 | 1914 | } |
| 1915 | 1915 | } |
| 1916 | 1916 | |
@@ -1940,20 +1940,20 @@ discard block |
||
| 1940 | 1940 | * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
| 1941 | 1941 | * @return array |
| 1942 | 1942 | */ |
| 1943 | -function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { |
|
| 1944 | - if ( !empty( $deprecated ) ) |
|
| 1945 | - _deprecated_argument( __FUNCTION__, '2.0' ); |
|
| 1943 | +function wp_upload_bits($name, $deprecated, $bits, $time = null) { |
|
| 1944 | + if ( ! empty($deprecated)) |
|
| 1945 | + _deprecated_argument(__FUNCTION__, '2.0'); |
|
| 1946 | 1946 | |
| 1947 | - if ( empty( $name ) ) |
|
| 1948 | - return array( 'error' => __( 'Empty filename' ) ); |
|
| 1947 | + if (empty($name)) |
|
| 1948 | + return array('error' => __('Empty filename')); |
|
| 1949 | 1949 | |
| 1950 | - $wp_filetype = wp_check_filetype( $name ); |
|
| 1951 | - if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) |
|
| 1952 | - return array( 'error' => __( 'Invalid file type' ) ); |
|
| 1950 | + $wp_filetype = wp_check_filetype($name); |
|
| 1951 | + if ( ! $wp_filetype['ext'] && ! current_user_can('unfiltered_upload')) |
|
| 1952 | + return array('error' => __('Invalid file type')); |
|
| 1953 | 1953 | |
| 1954 | - $upload = wp_upload_dir( $time ); |
|
| 1954 | + $upload = wp_upload_dir($time); |
|
| 1955 | 1955 | |
| 1956 | - if ( $upload['error'] !== false ) |
|
| 1956 | + if ($upload['error'] !== false) |
|
| 1957 | 1957 | return $upload; |
| 1958 | 1958 | |
| 1959 | 1959 | /** |
@@ -1966,44 +1966,44 @@ discard block |
||
| 1966 | 1966 | * |
| 1967 | 1967 | * @param mixed $upload_bits_error An array of upload bits data, or a non-array error to return. |
| 1968 | 1968 | */ |
| 1969 | - $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); |
|
| 1970 | - if ( !is_array( $upload_bits_error ) ) { |
|
| 1971 | - $upload[ 'error' ] = $upload_bits_error; |
|
| 1969 | + $upload_bits_error = apply_filters('wp_upload_bits', array('name' => $name, 'bits' => $bits, 'time' => $time)); |
|
| 1970 | + if ( ! is_array($upload_bits_error)) { |
|
| 1971 | + $upload['error'] = $upload_bits_error; |
|
| 1972 | 1972 | return $upload; |
| 1973 | 1973 | } |
| 1974 | 1974 | |
| 1975 | - $filename = wp_unique_filename( $upload['path'], $name ); |
|
| 1975 | + $filename = wp_unique_filename($upload['path'], $name); |
|
| 1976 | 1976 | |
| 1977 | - $new_file = $upload['path'] . "/$filename"; |
|
| 1978 | - if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { |
|
| 1979 | - if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) |
|
| 1980 | - $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; |
|
| 1977 | + $new_file = $upload['path']."/$filename"; |
|
| 1978 | + if ( ! wp_mkdir_p(dirname($new_file))) { |
|
| 1979 | + if (0 === strpos($upload['basedir'], ABSPATH)) |
|
| 1980 | + $error_path = str_replace(ABSPATH, '', $upload['basedir']).$upload['subdir']; |
|
| 1981 | 1981 | else |
| 1982 | - $error_path = basename( $upload['basedir'] ) . $upload['subdir']; |
|
| 1982 | + $error_path = basename($upload['basedir']).$upload['subdir']; |
|
| 1983 | 1983 | |
| 1984 | - $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); |
|
| 1985 | - return array( 'error' => $message ); |
|
| 1984 | + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $error_path); |
|
| 1985 | + return array('error' => $message); |
|
| 1986 | 1986 | } |
| 1987 | 1987 | |
| 1988 | - $ifp = @ fopen( $new_file, 'wb' ); |
|
| 1989 | - if ( ! $ifp ) |
|
| 1990 | - return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); |
|
| 1988 | + $ifp = @ fopen($new_file, 'wb'); |
|
| 1989 | + if ( ! $ifp) |
|
| 1990 | + return array('error' => sprintf(__('Could not write file %s'), $new_file)); |
|
| 1991 | 1991 | |
| 1992 | - @fwrite( $ifp, $bits ); |
|
| 1993 | - fclose( $ifp ); |
|
| 1992 | + @fwrite($ifp, $bits); |
|
| 1993 | + fclose($ifp); |
|
| 1994 | 1994 | clearstatcache(); |
| 1995 | 1995 | |
| 1996 | 1996 | // Set correct file permissions |
| 1997 | - $stat = @ stat( dirname( $new_file ) ); |
|
| 1997 | + $stat = @ stat(dirname($new_file)); |
|
| 1998 | 1998 | $perms = $stat['mode'] & 0007777; |
| 1999 | 1999 | $perms = $perms & 0000666; |
| 2000 | - @ chmod( $new_file, $perms ); |
|
| 2000 | + @ chmod($new_file, $perms); |
|
| 2001 | 2001 | clearstatcache(); |
| 2002 | 2002 | |
| 2003 | 2003 | // Compute the URL |
| 2004 | - $url = $upload['url'] . "/$filename"; |
|
| 2004 | + $url = $upload['url']."/$filename"; |
|
| 2005 | 2005 | |
| 2006 | - return array( 'file' => $new_file, 'url' => $url, 'error' => false ); |
|
| 2006 | + return array('file' => $new_file, 'url' => $url, 'error' => false); |
|
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | 2009 | /** |
@@ -2014,8 +2014,8 @@ discard block |
||
| 2014 | 2014 | * @param string $ext The extension to search. |
| 2015 | 2015 | * @return string|void The file type, example: audio, video, document, spreadsheet, etc. |
| 2016 | 2016 | */ |
| 2017 | -function wp_ext2type( $ext ) { |
|
| 2018 | - $ext = strtolower( $ext ); |
|
| 2017 | +function wp_ext2type($ext) { |
|
| 2018 | + $ext = strtolower($ext); |
|
| 2019 | 2019 | |
| 2020 | 2020 | /** |
| 2021 | 2021 | * Filter file type based on the extension name. |
@@ -2027,20 +2027,20 @@ discard block |
||
| 2027 | 2027 | * @param array $ext2type Multi-dimensional array with extensions for a default set |
| 2028 | 2028 | * of file types. |
| 2029 | 2029 | */ |
| 2030 | - $ext2type = apply_filters( 'ext2type', array( |
|
| 2031 | - 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), |
|
| 2032 | - 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), |
|
| 2033 | - 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), |
|
| 2034 | - 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), |
|
| 2035 | - 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), |
|
| 2036 | - 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), |
|
| 2037 | - 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), |
|
| 2038 | - 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ), |
|
| 2039 | - 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), |
|
| 2040 | - ) ); |
|
| 2041 | - |
|
| 2042 | - foreach ( $ext2type as $type => $exts ) |
|
| 2043 | - if ( in_array( $ext, $exts ) ) |
|
| 2030 | + $ext2type = apply_filters('ext2type', array( |
|
| 2031 | + 'image' => array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico'), |
|
| 2032 | + 'audio' => array('aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma'), |
|
| 2033 | + 'video' => array('3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv'), |
|
| 2034 | + 'document' => array('doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf'), |
|
| 2035 | + 'spreadsheet' => array('numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb'), |
|
| 2036 | + 'interactive' => array('swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp'), |
|
| 2037 | + 'text' => array('asc', 'csv', 'tsv', 'txt'), |
|
| 2038 | + 'archive' => array('bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z'), |
|
| 2039 | + 'code' => array('css', 'htm', 'html', 'php', 'js'), |
|
| 2040 | + )); |
|
| 2041 | + |
|
| 2042 | + foreach ($ext2type as $type => $exts) |
|
| 2043 | + if (in_array($ext, $exts)) |
|
| 2044 | 2044 | return $type; |
| 2045 | 2045 | } |
| 2046 | 2046 | |
@@ -2055,22 +2055,22 @@ discard block |
||
| 2055 | 2055 | * @param array $mimes Optional. Key is the file extension with value as the mime type. |
| 2056 | 2056 | * @return array Values with extension first and mime type. |
| 2057 | 2057 | */ |
| 2058 | -function wp_check_filetype( $filename, $mimes = null ) { |
|
| 2059 | - if ( empty($mimes) ) |
|
| 2058 | +function wp_check_filetype($filename, $mimes = null) { |
|
| 2059 | + if (empty($mimes)) |
|
| 2060 | 2060 | $mimes = get_allowed_mime_types(); |
| 2061 | 2061 | $type = false; |
| 2062 | 2062 | $ext = false; |
| 2063 | 2063 | |
| 2064 | - foreach ( $mimes as $ext_preg => $mime_match ) { |
|
| 2065 | - $ext_preg = '!\.(' . $ext_preg . ')$!i'; |
|
| 2066 | - if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { |
|
| 2064 | + foreach ($mimes as $ext_preg => $mime_match) { |
|
| 2065 | + $ext_preg = '!\.('.$ext_preg.')$!i'; |
|
| 2066 | + if (preg_match($ext_preg, $filename, $ext_matches)) { |
|
| 2067 | 2067 | $type = $mime_match; |
| 2068 | 2068 | $ext = $ext_matches[1]; |
| 2069 | 2069 | break; |
| 2070 | 2070 | } |
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | - return compact( 'ext', 'type' ); |
|
| 2073 | + return compact('ext', 'type'); |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | /** |
@@ -2092,27 +2092,27 @@ discard block |
||
| 2092 | 2092 | * @return array Values for the extension, MIME, and either a corrected filename or false |
| 2093 | 2093 | * if original $filename is valid. |
| 2094 | 2094 | */ |
| 2095 | -function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { |
|
| 2095 | +function wp_check_filetype_and_ext($file, $filename, $mimes = null) { |
|
| 2096 | 2096 | $proper_filename = false; |
| 2097 | 2097 | |
| 2098 | 2098 | // Do basic extension validation and MIME mapping |
| 2099 | - $wp_filetype = wp_check_filetype( $filename, $mimes ); |
|
| 2099 | + $wp_filetype = wp_check_filetype($filename, $mimes); |
|
| 2100 | 2100 | $ext = $wp_filetype['ext']; |
| 2101 | 2101 | $type = $wp_filetype['type']; |
| 2102 | 2102 | |
| 2103 | 2103 | // We can't do any further validation without a file to work with |
| 2104 | - if ( ! file_exists( $file ) ) { |
|
| 2105 | - return compact( 'ext', 'type', 'proper_filename' ); |
|
| 2104 | + if ( ! file_exists($file)) { |
|
| 2105 | + return compact('ext', 'type', 'proper_filename'); |
|
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | 2108 | // We're able to validate images using GD |
| 2109 | - if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) { |
|
| 2109 | + if ($type && 0 === strpos($type, 'image/') && function_exists('getimagesize')) { |
|
| 2110 | 2110 | |
| 2111 | 2111 | // Attempt to figure out what type of image it actually is |
| 2112 | - $imgstats = @getimagesize( $file ); |
|
| 2112 | + $imgstats = @getimagesize($file); |
|
| 2113 | 2113 | |
| 2114 | 2114 | // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME |
| 2115 | - if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) { |
|
| 2115 | + if ( ! empty($imgstats['mime']) && $imgstats['mime'] != $type) { |
|
| 2116 | 2116 | /** |
| 2117 | 2117 | * Filter the list mapping image mime types to their respective extensions. |
| 2118 | 2118 | * |
@@ -2120,26 +2120,26 @@ discard block |
||
| 2120 | 2120 | * |
| 2121 | 2121 | * @param array $mime_to_ext Array of image mime types and their matching extensions. |
| 2122 | 2122 | */ |
| 2123 | - $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( |
|
| 2123 | + $mime_to_ext = apply_filters('getimagesize_mimes_to_exts', array( |
|
| 2124 | 2124 | 'image/jpeg' => 'jpg', |
| 2125 | 2125 | 'image/png' => 'png', |
| 2126 | 2126 | 'image/gif' => 'gif', |
| 2127 | 2127 | 'image/bmp' => 'bmp', |
| 2128 | 2128 | 'image/tiff' => 'tif', |
| 2129 | - ) ); |
|
| 2129 | + )); |
|
| 2130 | 2130 | |
| 2131 | 2131 | // Replace whatever is after the last period in the filename with the correct extension |
| 2132 | - if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) { |
|
| 2133 | - $filename_parts = explode( '.', $filename ); |
|
| 2134 | - array_pop( $filename_parts ); |
|
| 2135 | - $filename_parts[] = $mime_to_ext[ $imgstats['mime'] ]; |
|
| 2136 | - $new_filename = implode( '.', $filename_parts ); |
|
| 2132 | + if ( ! empty($mime_to_ext[$imgstats['mime']])) { |
|
| 2133 | + $filename_parts = explode('.', $filename); |
|
| 2134 | + array_pop($filename_parts); |
|
| 2135 | + $filename_parts[] = $mime_to_ext[$imgstats['mime']]; |
|
| 2136 | + $new_filename = implode('.', $filename_parts); |
|
| 2137 | 2137 | |
| 2138 | - if ( $new_filename != $filename ) { |
|
| 2138 | + if ($new_filename != $filename) { |
|
| 2139 | 2139 | $proper_filename = $new_filename; // Mark that it changed |
| 2140 | 2140 | } |
| 2141 | 2141 | // Redefine the extension / MIME |
| 2142 | - $wp_filetype = wp_check_filetype( $new_filename, $mimes ); |
|
| 2142 | + $wp_filetype = wp_check_filetype($new_filename, $mimes); |
|
| 2143 | 2143 | $ext = $wp_filetype['ext']; |
| 2144 | 2144 | $type = $wp_filetype['type']; |
| 2145 | 2145 | } |
@@ -2158,7 +2158,7 @@ discard block |
||
| 2158 | 2158 | * $file being in a tmp directory). |
| 2159 | 2159 | * @param array $mimes Key is the file extension with value as the mime type. |
| 2160 | 2160 | */ |
| 2161 | - return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes ); |
|
| 2161 | + return apply_filters('wp_check_filetype_and_ext', compact('ext', 'type', 'proper_filename'), $file, $filename, $mimes); |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | /** |
@@ -2181,7 +2181,7 @@ discard block |
||
| 2181 | 2181 | * @param array $wp_get_mime_types Mime types keyed by the file extension regex |
| 2182 | 2182 | * corresponding to those types. |
| 2183 | 2183 | */ |
| 2184 | - return apply_filters( 'mime_types', array( |
|
| 2184 | + return apply_filters('mime_types', array( |
|
| 2185 | 2185 | // Image formats. |
| 2186 | 2186 | 'jpg|jpeg|jpe' => 'image/jpeg', |
| 2187 | 2187 | 'gif' => 'image/gif', |
@@ -2281,7 +2281,7 @@ discard block |
||
| 2281 | 2281 | 'key' => 'application/vnd.apple.keynote', |
| 2282 | 2282 | 'numbers' => 'application/vnd.apple.numbers', |
| 2283 | 2283 | 'pages' => 'application/vnd.apple.pages', |
| 2284 | - ) ); |
|
| 2284 | + )); |
|
| 2285 | 2285 | } |
| 2286 | 2286 | /** |
| 2287 | 2287 | * Retrieve list of allowed mime types and file extensions. |
@@ -2292,15 +2292,15 @@ discard block |
||
| 2292 | 2292 | * @return array Array of mime types keyed by the file extension regex corresponding |
| 2293 | 2293 | * to those types. |
| 2294 | 2294 | */ |
| 2295 | -function get_allowed_mime_types( $user = null ) { |
|
| 2295 | +function get_allowed_mime_types($user = null) { |
|
| 2296 | 2296 | $t = wp_get_mime_types(); |
| 2297 | 2297 | |
| 2298 | - unset( $t['swf'], $t['exe'] ); |
|
| 2299 | - if ( function_exists( 'current_user_can' ) ) |
|
| 2300 | - $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); |
|
| 2298 | + unset($t['swf'], $t['exe']); |
|
| 2299 | + if (function_exists('current_user_can')) |
|
| 2300 | + $unfiltered = $user ? user_can($user, 'unfiltered_html') : current_user_can('unfiltered_html'); |
|
| 2301 | 2301 | |
| 2302 | - if ( empty( $unfiltered ) ) |
|
| 2303 | - unset( $t['htm|html'] ); |
|
| 2302 | + if (empty($unfiltered)) |
|
| 2303 | + unset($t['htm|html']); |
|
| 2304 | 2304 | |
| 2305 | 2305 | /** |
| 2306 | 2306 | * Filter list of allowed mime types and file extensions. |
@@ -2312,7 +2312,7 @@ discard block |
||
| 2312 | 2312 | * removed depending on '$user' capabilities. |
| 2313 | 2313 | * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current user). |
| 2314 | 2314 | */ |
| 2315 | - return apply_filters( 'upload_mimes', $t, $user ); |
|
| 2315 | + return apply_filters('upload_mimes', $t, $user); |
|
| 2316 | 2316 | } |
| 2317 | 2317 | |
| 2318 | 2318 | /** |
@@ -2325,18 +2325,18 @@ discard block |
||
| 2325 | 2325 | * |
| 2326 | 2326 | * @param string $action The nonce action. |
| 2327 | 2327 | */ |
| 2328 | -function wp_nonce_ays( $action ) { |
|
| 2329 | - if ( 'log-out' == $action ) { |
|
| 2330 | - $html = sprintf( __( 'You are attempting to log out of %s' ), get_bloginfo( 'name' ) ) . '</p><p>'; |
|
| 2331 | - $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; |
|
| 2332 | - $html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url( $redirect_to ) ); |
|
| 2328 | +function wp_nonce_ays($action) { |
|
| 2329 | + if ('log-out' == $action) { |
|
| 2330 | + $html = sprintf(__('You are attempting to log out of %s'), get_bloginfo('name')).'</p><p>'; |
|
| 2331 | + $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; |
|
| 2332 | + $html .= sprintf(__("Do you really want to <a href='%s'>log out</a>?"), wp_logout_url($redirect_to)); |
|
| 2333 | 2333 | } else { |
| 2334 | - $html = __( 'Are you sure you want to do this?' ); |
|
| 2335 | - if ( wp_get_referer() ) |
|
| 2336 | - $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; |
|
| 2334 | + $html = __('Are you sure you want to do this?'); |
|
| 2335 | + if (wp_get_referer()) |
|
| 2336 | + $html .= "</p><p><a href='".esc_url(remove_query_arg('updated', wp_get_referer()))."'>".__('Please try again.')."</a>"; |
|
| 2337 | 2337 | } |
| 2338 | 2338 | |
| 2339 | - wp_die( $html, __( 'WordPress Failure Notice' ), 403 ); |
|
| 2339 | + wp_die($html, __('WordPress Failure Notice'), 403); |
|
| 2340 | 2340 | } |
| 2341 | 2341 | |
| 2342 | 2342 | /** |
@@ -2372,16 +2372,16 @@ discard block |
||
| 2372 | 2372 | * Default is the value of {@see is_rtl()}. |
| 2373 | 2373 | * } |
| 2374 | 2374 | */ |
| 2375 | -function wp_die( $message = '', $title = '', $args = array() ) { |
|
| 2375 | +function wp_die($message = '', $title = '', $args = array()) { |
|
| 2376 | 2376 | |
| 2377 | - if ( is_int( $args ) ) { |
|
| 2378 | - $args = array( 'response' => $args ); |
|
| 2379 | - } elseif ( is_int( $title ) ) { |
|
| 2380 | - $args = array( 'response' => $title ); |
|
| 2377 | + if (is_int($args)) { |
|
| 2378 | + $args = array('response' => $args); |
|
| 2379 | + } elseif (is_int($title)) { |
|
| 2380 | + $args = array('response' => $title); |
|
| 2381 | 2381 | $title = ''; |
| 2382 | 2382 | } |
| 2383 | 2383 | |
| 2384 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 2384 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2385 | 2385 | /** |
| 2386 | 2386 | * Filter callback for killing WordPress execution for AJAX requests. |
| 2387 | 2387 | * |
@@ -2389,8 +2389,8 @@ discard block |
||
| 2389 | 2389 | * |
| 2390 | 2390 | * @param callback $function Callback function name. |
| 2391 | 2391 | */ |
| 2392 | - $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); |
|
| 2393 | - } elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { |
|
| 2392 | + $function = apply_filters('wp_die_ajax_handler', '_ajax_wp_die_handler'); |
|
| 2393 | + } elseif (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { |
|
| 2394 | 2394 | /** |
| 2395 | 2395 | * Filter callback for killing WordPress execution for XML-RPC requests. |
| 2396 | 2396 | * |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | * |
| 2399 | 2399 | * @param callback $function Callback function name. |
| 2400 | 2400 | */ |
| 2401 | - $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); |
|
| 2401 | + $function = apply_filters('wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler'); |
|
| 2402 | 2402 | } else { |
| 2403 | 2403 | /** |
| 2404 | 2404 | * Filter callback for killing WordPress execution for all non-AJAX, non-XML-RPC requests. |
@@ -2407,10 +2407,10 @@ discard block |
||
| 2407 | 2407 | * |
| 2408 | 2408 | * @param callback $function Callback function name. |
| 2409 | 2409 | */ |
| 2410 | - $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); |
|
| 2410 | + $function = apply_filters('wp_die_handler', '_default_wp_die_handler'); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | - call_user_func( $function, $message, $title, $args ); |
|
| 2413 | + call_user_func($function, $message, $title, $args); |
|
| 2414 | 2414 | } |
| 2415 | 2415 | |
| 2416 | 2416 | /** |
@@ -2426,20 +2426,20 @@ discard block |
||
| 2426 | 2426 | * @param string $title Optional. Error title. Default empty. |
| 2427 | 2427 | * @param string|array $args Optional. Arguments to control behavior. Default empty array. |
| 2428 | 2428 | */ |
| 2429 | -function _default_wp_die_handler( $message, $title = '', $args = array() ) { |
|
| 2430 | - $defaults = array( 'response' => 500 ); |
|
| 2429 | +function _default_wp_die_handler($message, $title = '', $args = array()) { |
|
| 2430 | + $defaults = array('response' => 500); |
|
| 2431 | 2431 | $r = wp_parse_args($args, $defaults); |
| 2432 | 2432 | |
| 2433 | 2433 | $have_gettext = function_exists('__'); |
| 2434 | 2434 | |
| 2435 | - if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { |
|
| 2436 | - if ( empty( $title ) ) { |
|
| 2435 | + if (function_exists('is_wp_error') && is_wp_error($message)) { |
|
| 2436 | + if (empty($title)) { |
|
| 2437 | 2437 | $error_data = $message->get_error_data(); |
| 2438 | - if ( is_array( $error_data ) && isset( $error_data['title'] ) ) |
|
| 2438 | + if (is_array($error_data) && isset($error_data['title'])) |
|
| 2439 | 2439 | $title = $error_data['title']; |
| 2440 | 2440 | } |
| 2441 | 2441 | $errors = $message->get_error_messages(); |
| 2442 | - switch ( count( $errors ) ) { |
|
| 2442 | + switch (count($errors)) { |
|
| 2443 | 2443 | case 0 : |
| 2444 | 2444 | $message = ''; |
| 2445 | 2445 | break; |
@@ -2447,38 +2447,38 @@ discard block |
||
| 2447 | 2447 | $message = "<p>{$errors[0]}</p>"; |
| 2448 | 2448 | break; |
| 2449 | 2449 | default : |
| 2450 | - $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; |
|
| 2450 | + $message = "<ul>\n\t\t<li>".join("</li>\n\t\t<li>", $errors)."</li>\n\t</ul>"; |
|
| 2451 | 2451 | break; |
| 2452 | 2452 | } |
| 2453 | - } elseif ( is_string( $message ) ) { |
|
| 2453 | + } elseif (is_string($message)) { |
|
| 2454 | 2454 | $message = "<p>$message</p>"; |
| 2455 | 2455 | } |
| 2456 | 2456 | |
| 2457 | - if ( isset( $r['back_link'] ) && $r['back_link'] ) { |
|
| 2458 | - $back_text = $have_gettext? __('« Back') : '« Back'; |
|
| 2457 | + if (isset($r['back_link']) && $r['back_link']) { |
|
| 2458 | + $back_text = $have_gettext ? __('« Back') : '« Back'; |
|
| 2459 | 2459 | $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>"; |
| 2460 | 2460 | } |
| 2461 | 2461 | |
| 2462 | - if ( ! did_action( 'admin_head' ) ) : |
|
| 2463 | - if ( !headers_sent() ) { |
|
| 2464 | - status_header( $r['response'] ); |
|
| 2462 | + if ( ! did_action('admin_head')) : |
|
| 2463 | + if ( ! headers_sent()) { |
|
| 2464 | + status_header($r['response']); |
|
| 2465 | 2465 | nocache_headers(); |
| 2466 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 2466 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 2467 | 2467 | } |
| 2468 | 2468 | |
| 2469 | - if ( empty($title) ) |
|
| 2469 | + if (empty($title)) |
|
| 2470 | 2470 | $title = $have_gettext ? __('WordPress › Error') : 'WordPress › Error'; |
| 2471 | 2471 | |
| 2472 | 2472 | $text_direction = 'ltr'; |
| 2473 | - if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] ) |
|
| 2473 | + if (isset($r['text_direction']) && 'rtl' == $r['text_direction']) |
|
| 2474 | 2474 | $text_direction = 'rtl'; |
| 2475 | - elseif ( function_exists( 'is_rtl' ) && is_rtl() ) |
|
| 2475 | + elseif (function_exists('is_rtl') && is_rtl()) |
|
| 2476 | 2476 | $text_direction = 'rtl'; |
| 2477 | 2477 | ?> |
| 2478 | 2478 | <!DOCTYPE html> |
| 2479 | 2479 | <!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono |
| 2480 | 2480 | --> |
| 2481 | -<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>> |
|
| 2481 | +<html xmlns="http://www.w3.org/1999/xhtml" <?php if (function_exists('language_attributes') && function_exists('is_rtl')) language_attributes(); else echo "dir='$text_direction'"; ?>> |
|
| 2482 | 2482 | <head> |
| 2483 | 2483 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 2484 | 2484 | <meta name="viewport" content="width=device-width"> |
@@ -2579,7 +2579,7 @@ discard block |
||
| 2579 | 2579 | box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); |
| 2580 | 2580 | } |
| 2581 | 2581 | |
| 2582 | - <?php if ( 'rtl' == $text_direction ) : ?> |
|
| 2582 | + <?php if ('rtl' == $text_direction) : ?> |
|
| 2583 | 2583 | body { font-family: Tahoma, Arial; } |
| 2584 | 2584 | <?php endif; ?> |
| 2585 | 2585 | </style> |
@@ -2607,15 +2607,15 @@ discard block |
||
| 2607 | 2607 | * @param string $title Optional. Error title. Default empty. |
| 2608 | 2608 | * @param string|array $args Optional. Arguments to control behavior. Default empty array. |
| 2609 | 2609 | */ |
| 2610 | -function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { |
|
| 2610 | +function _xmlrpc_wp_die_handler($message, $title = '', $args = array()) { |
|
| 2611 | 2611 | global $wp_xmlrpc_server; |
| 2612 | - $defaults = array( 'response' => 500 ); |
|
| 2612 | + $defaults = array('response' => 500); |
|
| 2613 | 2613 | |
| 2614 | 2614 | $r = wp_parse_args($args, $defaults); |
| 2615 | 2615 | |
| 2616 | - if ( $wp_xmlrpc_server ) { |
|
| 2617 | - $error = new IXR_Error( $r['response'] , $message); |
|
| 2618 | - $wp_xmlrpc_server->output( $error->getXml() ); |
|
| 2616 | + if ($wp_xmlrpc_server) { |
|
| 2617 | + $error = new IXR_Error($r['response'], $message); |
|
| 2618 | + $wp_xmlrpc_server->output($error->getXml()); |
|
| 2619 | 2619 | } |
| 2620 | 2620 | die(); |
| 2621 | 2621 | } |
@@ -2630,10 +2630,10 @@ discard block |
||
| 2630 | 2630 | * |
| 2631 | 2631 | * @param string $message Optional. Response to print. Default empty. |
| 2632 | 2632 | */ |
| 2633 | -function _ajax_wp_die_handler( $message = '' ) { |
|
| 2634 | - if ( is_scalar( $message ) ) |
|
| 2635 | - die( (string) $message ); |
|
| 2636 | - die( '0' ); |
|
| 2633 | +function _ajax_wp_die_handler($message = '') { |
|
| 2634 | + if (is_scalar($message)) |
|
| 2635 | + die((string) $message); |
|
| 2636 | + die('0'); |
|
| 2637 | 2637 | } |
| 2638 | 2638 | |
| 2639 | 2639 | /** |
@@ -2646,9 +2646,9 @@ discard block |
||
| 2646 | 2646 | * |
| 2647 | 2647 | * @param string $message Optional. Response to print. Default empty. |
| 2648 | 2648 | */ |
| 2649 | -function _scalar_wp_die_handler( $message = '' ) { |
|
| 2650 | - if ( is_scalar( $message ) ) |
|
| 2651 | - die( (string) $message ); |
|
| 2649 | +function _scalar_wp_die_handler($message = '') { |
|
| 2650 | + if (is_scalar($message)) |
|
| 2651 | + die((string) $message); |
|
| 2652 | 2652 | die(); |
| 2653 | 2653 | } |
| 2654 | 2654 | |
@@ -2663,36 +2663,36 @@ discard block |
||
| 2663 | 2663 | * greater than 0. Default 512. |
| 2664 | 2664 | * @return string|false The JSON encoded string, or false if it cannot be encoded. |
| 2665 | 2665 | */ |
| 2666 | -function wp_json_encode( $data, $options = 0, $depth = 512 ) { |
|
| 2666 | +function wp_json_encode($data, $options = 0, $depth = 512) { |
|
| 2667 | 2667 | /* |
| 2668 | 2668 | * json_encode() has had extra params added over the years. |
| 2669 | 2669 | * $options was added in 5.3, and $depth in 5.5. |
| 2670 | 2670 | * We need to make sure we call it with the correct arguments. |
| 2671 | 2671 | */ |
| 2672 | - if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) { |
|
| 2673 | - $args = array( $data, $options, $depth ); |
|
| 2674 | - } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) { |
|
| 2675 | - $args = array( $data, $options ); |
|
| 2672 | + if (version_compare(PHP_VERSION, '5.5', '>=')) { |
|
| 2673 | + $args = array($data, $options, $depth); |
|
| 2674 | + } elseif (version_compare(PHP_VERSION, '5.3', '>=')) { |
|
| 2675 | + $args = array($data, $options); |
|
| 2676 | 2676 | } else { |
| 2677 | - $args = array( $data ); |
|
| 2677 | + $args = array($data); |
|
| 2678 | 2678 | } |
| 2679 | 2679 | |
| 2680 | - $json = call_user_func_array( 'json_encode', $args ); |
|
| 2680 | + $json = call_user_func_array('json_encode', $args); |
|
| 2681 | 2681 | |
| 2682 | 2682 | // If json_encode() was successful, no need to do more sanity checking. |
| 2683 | 2683 | // ... unless we're in an old version of PHP, and json_encode() returned |
| 2684 | 2684 | // a string containing 'null'. Then we need to do more sanity checking. |
| 2685 | - if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) { |
|
| 2685 | + if (false !== $json && (version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null'))) { |
|
| 2686 | 2686 | return $json; |
| 2687 | 2687 | } |
| 2688 | 2688 | |
| 2689 | 2689 | try { |
| 2690 | - $args[0] = _wp_json_sanity_check( $data, $depth ); |
|
| 2691 | - } catch ( Exception $e ) { |
|
| 2690 | + $args[0] = _wp_json_sanity_check($data, $depth); |
|
| 2691 | + } catch (Exception $e) { |
|
| 2692 | 2692 | return false; |
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | - return call_user_func_array( 'json_encode', $args ); |
|
| 2695 | + return call_user_func_array('json_encode', $args); |
|
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | /** |
@@ -2708,49 +2708,49 @@ discard block |
||
| 2708 | 2708 | * @param int $depth Maximum depth to walk through $data. Must be greater than 0. |
| 2709 | 2709 | * @return mixed The sanitized data that shall be encoded to JSON. |
| 2710 | 2710 | */ |
| 2711 | -function _wp_json_sanity_check( $data, $depth ) { |
|
| 2712 | - if ( $depth < 0 ) { |
|
| 2713 | - throw new Exception( 'Reached depth limit' ); |
|
| 2711 | +function _wp_json_sanity_check($data, $depth) { |
|
| 2712 | + if ($depth < 0) { |
|
| 2713 | + throw new Exception('Reached depth limit'); |
|
| 2714 | 2714 | } |
| 2715 | 2715 | |
| 2716 | - if ( is_array( $data ) ) { |
|
| 2716 | + if (is_array($data)) { |
|
| 2717 | 2717 | $output = array(); |
| 2718 | - foreach ( $data as $id => $el ) { |
|
| 2718 | + foreach ($data as $id => $el) { |
|
| 2719 | 2719 | // Don't forget to sanitize the ID! |
| 2720 | - if ( is_string( $id ) ) { |
|
| 2721 | - $clean_id = _wp_json_convert_string( $id ); |
|
| 2720 | + if (is_string($id)) { |
|
| 2721 | + $clean_id = _wp_json_convert_string($id); |
|
| 2722 | 2722 | } else { |
| 2723 | 2723 | $clean_id = $id; |
| 2724 | 2724 | } |
| 2725 | 2725 | |
| 2726 | 2726 | // Check the element type, so that we're only recursing if we really have to. |
| 2727 | - if ( is_array( $el ) || is_object( $el ) ) { |
|
| 2728 | - $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 ); |
|
| 2729 | - } elseif ( is_string( $el ) ) { |
|
| 2730 | - $output[ $clean_id ] = _wp_json_convert_string( $el ); |
|
| 2727 | + if (is_array($el) || is_object($el)) { |
|
| 2728 | + $output[$clean_id] = _wp_json_sanity_check($el, $depth - 1); |
|
| 2729 | + } elseif (is_string($el)) { |
|
| 2730 | + $output[$clean_id] = _wp_json_convert_string($el); |
|
| 2731 | 2731 | } else { |
| 2732 | - $output[ $clean_id ] = $el; |
|
| 2732 | + $output[$clean_id] = $el; |
|
| 2733 | 2733 | } |
| 2734 | 2734 | } |
| 2735 | - } elseif ( is_object( $data ) ) { |
|
| 2735 | + } elseif (is_object($data)) { |
|
| 2736 | 2736 | $output = new stdClass; |
| 2737 | - foreach ( $data as $id => $el ) { |
|
| 2738 | - if ( is_string( $id ) ) { |
|
| 2739 | - $clean_id = _wp_json_convert_string( $id ); |
|
| 2737 | + foreach ($data as $id => $el) { |
|
| 2738 | + if (is_string($id)) { |
|
| 2739 | + $clean_id = _wp_json_convert_string($id); |
|
| 2740 | 2740 | } else { |
| 2741 | 2741 | $clean_id = $id; |
| 2742 | 2742 | } |
| 2743 | 2743 | |
| 2744 | - if ( is_array( $el ) || is_object( $el ) ) { |
|
| 2745 | - $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 ); |
|
| 2746 | - } elseif ( is_string( $el ) ) { |
|
| 2747 | - $output->$clean_id = _wp_json_convert_string( $el ); |
|
| 2744 | + if (is_array($el) || is_object($el)) { |
|
| 2745 | + $output->$clean_id = _wp_json_sanity_check($el, $depth - 1); |
|
| 2746 | + } elseif (is_string($el)) { |
|
| 2747 | + $output->$clean_id = _wp_json_convert_string($el); |
|
| 2748 | 2748 | } else { |
| 2749 | 2749 | $output->$clean_id = $el; |
| 2750 | 2750 | } |
| 2751 | 2751 | } |
| 2752 | - } elseif ( is_string( $data ) ) { |
|
| 2753 | - return _wp_json_convert_string( $data ); |
|
| 2752 | + } elseif (is_string($data)) { |
|
| 2753 | + return _wp_json_convert_string($data); |
|
| 2754 | 2754 | } else { |
| 2755 | 2755 | return $data; |
| 2756 | 2756 | } |
@@ -2772,21 +2772,21 @@ discard block |
||
| 2772 | 2772 | * @param string $string The string which is to be converted. |
| 2773 | 2773 | * @return string The checked string. |
| 2774 | 2774 | */ |
| 2775 | -function _wp_json_convert_string( $string ) { |
|
| 2775 | +function _wp_json_convert_string($string) { |
|
| 2776 | 2776 | static $use_mb = null; |
| 2777 | - if ( is_null( $use_mb ) ) { |
|
| 2778 | - $use_mb = function_exists( 'mb_convert_encoding' ); |
|
| 2777 | + if (is_null($use_mb)) { |
|
| 2778 | + $use_mb = function_exists('mb_convert_encoding'); |
|
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | - if ( $use_mb ) { |
|
| 2782 | - $encoding = mb_detect_encoding( $string, mb_detect_order(), true ); |
|
| 2783 | - if ( $encoding ) { |
|
| 2784 | - return mb_convert_encoding( $string, 'UTF-8', $encoding ); |
|
| 2781 | + if ($use_mb) { |
|
| 2782 | + $encoding = mb_detect_encoding($string, mb_detect_order(), true); |
|
| 2783 | + if ($encoding) { |
|
| 2784 | + return mb_convert_encoding($string, 'UTF-8', $encoding); |
|
| 2785 | 2785 | } else { |
| 2786 | - return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' ); |
|
| 2786 | + return mb_convert_encoding($string, 'UTF-8', 'UTF-8'); |
|
| 2787 | 2787 | } |
| 2788 | 2788 | } else { |
| 2789 | - return wp_check_invalid_utf8( $string, true ); |
|
| 2789 | + return wp_check_invalid_utf8($string, true); |
|
| 2790 | 2790 | } |
| 2791 | 2791 | } |
| 2792 | 2792 | |
@@ -2798,10 +2798,10 @@ discard block |
||
| 2798 | 2798 | * @param mixed $response Variable (usually an array or object) to encode as JSON, |
| 2799 | 2799 | * then print and die. |
| 2800 | 2800 | */ |
| 2801 | -function wp_send_json( $response ) { |
|
| 2802 | - @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
|
| 2803 | - echo wp_json_encode( $response ); |
|
| 2804 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
| 2801 | +function wp_send_json($response) { |
|
| 2802 | + @header('Content-Type: application/json; charset='.get_option('blog_charset')); |
|
| 2803 | + echo wp_json_encode($response); |
|
| 2804 | + if (defined('DOING_AJAX') && DOING_AJAX) |
|
| 2805 | 2805 | wp_die(); |
| 2806 | 2806 | else |
| 2807 | 2807 | die; |
@@ -2814,13 +2814,13 @@ discard block |
||
| 2814 | 2814 | * |
| 2815 | 2815 | * @param mixed $data Data to encode as JSON, then print and die. |
| 2816 | 2816 | */ |
| 2817 | -function wp_send_json_success( $data = null ) { |
|
| 2818 | - $response = array( 'success' => true ); |
|
| 2817 | +function wp_send_json_success($data = null) { |
|
| 2818 | + $response = array('success' => true); |
|
| 2819 | 2819 | |
| 2820 | - if ( isset( $data ) ) |
|
| 2820 | + if (isset($data)) |
|
| 2821 | 2821 | $response['data'] = $data; |
| 2822 | 2822 | |
| 2823 | - wp_send_json( $response ); |
|
| 2823 | + wp_send_json($response); |
|
| 2824 | 2824 | } |
| 2825 | 2825 | |
| 2826 | 2826 | /** |
@@ -2837,15 +2837,15 @@ discard block |
||
| 2837 | 2837 | * |
| 2838 | 2838 | * @param mixed $data Data to encode as JSON, then print and die. |
| 2839 | 2839 | */ |
| 2840 | -function wp_send_json_error( $data = null ) { |
|
| 2841 | - $response = array( 'success' => false ); |
|
| 2840 | +function wp_send_json_error($data = null) { |
|
| 2841 | + $response = array('success' => false); |
|
| 2842 | 2842 | |
| 2843 | - if ( isset( $data ) ) { |
|
| 2844 | - if ( is_wp_error( $data ) ) { |
|
| 2843 | + if (isset($data)) { |
|
| 2844 | + if (is_wp_error($data)) { |
|
| 2845 | 2845 | $result = array(); |
| 2846 | - foreach ( $data->errors as $code => $messages ) { |
|
| 2847 | - foreach ( $messages as $message ) { |
|
| 2848 | - $result[] = array( 'code' => $code, 'message' => $message ); |
|
| 2846 | + foreach ($data->errors as $code => $messages) { |
|
| 2847 | + foreach ($messages as $message) { |
|
| 2848 | + $result[] = array('code' => $code, 'message' => $message); |
|
| 2849 | 2849 | } |
| 2850 | 2850 | } |
| 2851 | 2851 | |
@@ -2855,7 +2855,7 @@ discard block |
||
| 2855 | 2855 | } |
| 2856 | 2856 | } |
| 2857 | 2857 | |
| 2858 | - wp_send_json( $response ); |
|
| 2858 | + wp_send_json($response); |
|
| 2859 | 2859 | } |
| 2860 | 2860 | |
| 2861 | 2861 | /** |
@@ -2873,9 +2873,9 @@ discard block |
||
| 2873 | 2873 | * @param string $url URL for the home location. |
| 2874 | 2874 | * @return string Homepage location. |
| 2875 | 2875 | */ |
| 2876 | -function _config_wp_home( $url = '' ) { |
|
| 2877 | - if ( defined( 'WP_HOME' ) ) |
|
| 2878 | - return untrailingslashit( WP_HOME ); |
|
| 2876 | +function _config_wp_home($url = '') { |
|
| 2877 | + if (defined('WP_HOME')) |
|
| 2878 | + return untrailingslashit(WP_HOME); |
|
| 2879 | 2879 | return $url; |
| 2880 | 2880 | } |
| 2881 | 2881 | |
@@ -2894,9 +2894,9 @@ discard block |
||
| 2894 | 2894 | * @param string $url URL to set the WordPress site location. |
| 2895 | 2895 | * @return string The WordPress Site URL. |
| 2896 | 2896 | */ |
| 2897 | -function _config_wp_siteurl( $url = '' ) { |
|
| 2898 | - if ( defined( 'WP_SITEURL' ) ) |
|
| 2899 | - return untrailingslashit( WP_SITEURL ); |
|
| 2897 | +function _config_wp_siteurl($url = '') { |
|
| 2898 | + if (defined('WP_SITEURL')) |
|
| 2899 | + return untrailingslashit(WP_SITEURL); |
|
| 2900 | 2900 | return $url; |
| 2901 | 2901 | } |
| 2902 | 2902 | |
@@ -2917,15 +2917,15 @@ discard block |
||
| 2917 | 2917 | * @param array $input MCE settings array. |
| 2918 | 2918 | * @return array Direction set for 'rtl', if needed by locale. |
| 2919 | 2919 | */ |
| 2920 | -function _mce_set_direction( $input ) { |
|
| 2921 | - if ( is_rtl() ) { |
|
| 2920 | +function _mce_set_direction($input) { |
|
| 2921 | + if (is_rtl()) { |
|
| 2922 | 2922 | $input['directionality'] = 'rtl'; |
| 2923 | 2923 | |
| 2924 | - if ( ! empty( $input['plugins'] ) && strpos( $input['plugins'], 'directionality' ) === false ) { |
|
| 2924 | + if ( ! empty($input['plugins']) && strpos($input['plugins'], 'directionality') === false) { |
|
| 2925 | 2925 | $input['plugins'] .= ',directionality'; |
| 2926 | 2926 | } |
| 2927 | 2927 | |
| 2928 | - if ( ! empty( $input['toolbar1'] ) && ! preg_match( '/\bltr\b/', $input['toolbar1'] ) ) { |
|
| 2928 | + if ( ! empty($input['toolbar1']) && ! preg_match('/\bltr\b/', $input['toolbar1'])) { |
|
| 2929 | 2929 | $input['toolbar1'] .= ',ltr'; |
| 2930 | 2930 | } |
| 2931 | 2931 | } |
@@ -2960,10 +2960,10 @@ discard block |
||
| 2960 | 2960 | global $wpsmiliestrans, $wp_smiliessearch; |
| 2961 | 2961 | |
| 2962 | 2962 | // don't bother setting up smilies if they are disabled |
| 2963 | - if ( !get_option( 'use_smilies' ) ) |
|
| 2963 | + if ( ! get_option('use_smilies')) |
|
| 2964 | 2964 | return; |
| 2965 | 2965 | |
| 2966 | - if ( !isset( $wpsmiliestrans ) ) { |
|
| 2966 | + if ( ! isset($wpsmiliestrans)) { |
|
| 2967 | 2967 | $wpsmiliestrans = array( |
| 2968 | 2968 | ':mrgreen:' => 'mrgreen.png', |
| 2969 | 2969 | ':neutral:' => "\xf0\x9f\x98\x90", |
@@ -3027,28 +3027,28 @@ discard block |
||
| 3027 | 3027 | $spaces = wp_spaces_regexp(); |
| 3028 | 3028 | |
| 3029 | 3029 | // Begin first "subpattern" |
| 3030 | - $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; |
|
| 3030 | + $wp_smiliessearch = '/(?<='.$spaces.'|^)'; |
|
| 3031 | 3031 | |
| 3032 | 3032 | $subchar = ''; |
| 3033 | - foreach ( (array) $wpsmiliestrans as $smiley => $img ) { |
|
| 3033 | + foreach ((array) $wpsmiliestrans as $smiley => $img) { |
|
| 3034 | 3034 | $firstchar = substr($smiley, 0, 1); |
| 3035 | 3035 | $rest = substr($smiley, 1); |
| 3036 | 3036 | |
| 3037 | 3037 | // new subpattern? |
| 3038 | 3038 | if ($firstchar != $subchar) { |
| 3039 | 3039 | if ($subchar != '') { |
| 3040 | - $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" |
|
| 3041 | - $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" |
|
| 3040 | + $wp_smiliessearch .= ')(?='.$spaces.'|$)'; // End previous "subpattern" |
|
| 3041 | + $wp_smiliessearch .= '|(?<='.$spaces.'|^)'; // Begin another "subpattern" |
|
| 3042 | 3042 | } |
| 3043 | 3043 | $subchar = $firstchar; |
| 3044 | - $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:'; |
|
| 3044 | + $wp_smiliessearch .= preg_quote($firstchar, '/').'(?:'; |
|
| 3045 | 3045 | } else { |
| 3046 | 3046 | $wp_smiliessearch .= '|'; |
| 3047 | 3047 | } |
| 3048 | 3048 | $wp_smiliessearch .= preg_quote($rest, '/'); |
| 3049 | 3049 | } |
| 3050 | 3050 | |
| 3051 | - $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m'; |
|
| 3051 | + $wp_smiliessearch .= ')(?='.$spaces.'|$)/m'; |
|
| 3052 | 3052 | |
| 3053 | 3053 | } |
| 3054 | 3054 | |
@@ -3064,16 +3064,16 @@ discard block |
||
| 3064 | 3064 | * @param array $defaults Optional. Array that serves as the defaults. Default empty. |
| 3065 | 3065 | * @return array Merged user defined values with defaults. |
| 3066 | 3066 | */ |
| 3067 | -function wp_parse_args( $args, $defaults = '' ) { |
|
| 3068 | - if ( is_object( $args ) ) |
|
| 3069 | - $r = get_object_vars( $args ); |
|
| 3070 | - elseif ( is_array( $args ) ) |
|
| 3071 | - $r =& $args; |
|
| 3067 | +function wp_parse_args($args, $defaults = '') { |
|
| 3068 | + if (is_object($args)) |
|
| 3069 | + $r = get_object_vars($args); |
|
| 3070 | + elseif (is_array($args)) |
|
| 3071 | + $r = & $args; |
|
| 3072 | 3072 | else |
| 3073 | - wp_parse_str( $args, $r ); |
|
| 3073 | + wp_parse_str($args, $r); |
|
| 3074 | 3074 | |
| 3075 | - if ( is_array( $defaults ) ) |
|
| 3076 | - return array_merge( $defaults, $r ); |
|
| 3075 | + if (is_array($defaults)) |
|
| 3076 | + return array_merge($defaults, $r); |
|
| 3077 | 3077 | return $r; |
| 3078 | 3078 | } |
| 3079 | 3079 | |
@@ -3085,8 +3085,8 @@ discard block |
||
| 3085 | 3085 | * @param array|string $list List of ids. |
| 3086 | 3086 | * @return array Sanitized array of IDs. |
| 3087 | 3087 | */ |
| 3088 | -function wp_parse_id_list( $list ) { |
|
| 3089 | - if ( !is_array($list) ) |
|
| 3088 | +function wp_parse_id_list($list) { |
|
| 3089 | + if ( ! is_array($list)) |
|
| 3090 | 3090 | $list = preg_split('/[\s,]+/', $list); |
| 3091 | 3091 | |
| 3092 | 3092 | return array_unique(array_map('absint', $list)); |
@@ -3101,11 +3101,11 @@ discard block |
||
| 3101 | 3101 | * @param array $keys The list of keys. |
| 3102 | 3102 | * @return array The array slice. |
| 3103 | 3103 | */ |
| 3104 | -function wp_array_slice_assoc( $array, $keys ) { |
|
| 3104 | +function wp_array_slice_assoc($array, $keys) { |
|
| 3105 | 3105 | $slice = array(); |
| 3106 | - foreach ( $keys as $key ) |
|
| 3107 | - if ( isset( $array[ $key ] ) ) |
|
| 3108 | - $slice[ $key ] = $array[ $key ]; |
|
| 3106 | + foreach ($keys as $key) |
|
| 3107 | + if (isset($array[$key])) |
|
| 3108 | + $slice[$key] = $array[$key]; |
|
| 3109 | 3109 | |
| 3110 | 3110 | return $slice; |
| 3111 | 3111 | } |
@@ -3125,14 +3125,14 @@ discard block |
||
| 3125 | 3125 | * Default false. |
| 3126 | 3126 | * @return array A list of objects or object fields. |
| 3127 | 3127 | */ |
| 3128 | -function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { |
|
| 3129 | - if ( ! is_array( $list ) ) |
|
| 3128 | +function wp_filter_object_list($list, $args = array(), $operator = 'and', $field = false) { |
|
| 3129 | + if ( ! is_array($list)) |
|
| 3130 | 3130 | return array(); |
| 3131 | 3131 | |
| 3132 | - $list = wp_list_filter( $list, $args, $operator ); |
|
| 3132 | + $list = wp_list_filter($list, $args, $operator); |
|
| 3133 | 3133 | |
| 3134 | - if ( $field ) |
|
| 3135 | - $list = wp_list_pluck( $list, $field ); |
|
| 3134 | + if ($field) |
|
| 3135 | + $list = wp_list_pluck($list, $field); |
|
| 3136 | 3136 | |
| 3137 | 3137 | return $list; |
| 3138 | 3138 | } |
@@ -3151,29 +3151,29 @@ discard block |
||
| 3151 | 3151 | * match. Default 'AND'. |
| 3152 | 3152 | * @return array Array of found values. |
| 3153 | 3153 | */ |
| 3154 | -function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { |
|
| 3155 | - if ( ! is_array( $list ) ) |
|
| 3154 | +function wp_list_filter($list, $args = array(), $operator = 'AND') { |
|
| 3155 | + if ( ! is_array($list)) |
|
| 3156 | 3156 | return array(); |
| 3157 | 3157 | |
| 3158 | - if ( empty( $args ) ) |
|
| 3158 | + if (empty($args)) |
|
| 3159 | 3159 | return $list; |
| 3160 | 3160 | |
| 3161 | - $operator = strtoupper( $operator ); |
|
| 3162 | - $count = count( $args ); |
|
| 3161 | + $operator = strtoupper($operator); |
|
| 3162 | + $count = count($args); |
|
| 3163 | 3163 | $filtered = array(); |
| 3164 | 3164 | |
| 3165 | - foreach ( $list as $key => $obj ) { |
|
| 3165 | + foreach ($list as $key => $obj) { |
|
| 3166 | 3166 | $to_match = (array) $obj; |
| 3167 | 3167 | |
| 3168 | 3168 | $matched = 0; |
| 3169 | - foreach ( $args as $m_key => $m_value ) { |
|
| 3170 | - if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) |
|
| 3169 | + foreach ($args as $m_key => $m_value) { |
|
| 3170 | + if (array_key_exists($m_key, $to_match) && $m_value == $to_match[$m_key]) |
|
| 3171 | 3171 | $matched++; |
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | - if ( ( 'AND' == $operator && $matched == $count ) |
|
| 3175 | - || ( 'OR' == $operator && $matched > 0 ) |
|
| 3176 | - || ( 'NOT' == $operator && 0 == $matched ) ) { |
|
| 3174 | + if (('AND' == $operator && $matched == $count) |
|
| 3175 | + || ('OR' == $operator && $matched > 0) |
|
| 3176 | + || ('NOT' == $operator && 0 == $matched)) { |
|
| 3177 | 3177 | $filtered[$key] = $obj; |
| 3178 | 3178 | } |
| 3179 | 3179 | } |
@@ -3198,17 +3198,17 @@ discard block |
||
| 3198 | 3198 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
| 3199 | 3199 | * `$list` will be preserved in the results. |
| 3200 | 3200 | */ |
| 3201 | -function wp_list_pluck( $list, $field, $index_key = null ) { |
|
| 3202 | - if ( ! $index_key ) { |
|
| 3201 | +function wp_list_pluck($list, $field, $index_key = null) { |
|
| 3202 | + if ( ! $index_key) { |
|
| 3203 | 3203 | /* |
| 3204 | 3204 | * This is simple. Could at some point wrap array_column() |
| 3205 | 3205 | * if we knew we had an array of arrays. |
| 3206 | 3206 | */ |
| 3207 | - foreach ( $list as $key => $value ) { |
|
| 3208 | - if ( is_object( $value ) ) { |
|
| 3209 | - $list[ $key ] = $value->$field; |
|
| 3207 | + foreach ($list as $key => $value) { |
|
| 3208 | + if (is_object($value)) { |
|
| 3209 | + $list[$key] = $value->$field; |
|
| 3210 | 3210 | } else { |
| 3211 | - $list[ $key ] = $value[ $field ]; |
|
| 3211 | + $list[$key] = $value[$field]; |
|
| 3212 | 3212 | } |
| 3213 | 3213 | } |
| 3214 | 3214 | return $list; |
@@ -3219,18 +3219,18 @@ discard block |
||
| 3219 | 3219 | * to the end of the stack. This is how array_column() behaves. |
| 3220 | 3220 | */ |
| 3221 | 3221 | $newlist = array(); |
| 3222 | - foreach ( $list as $value ) { |
|
| 3223 | - if ( is_object( $value ) ) { |
|
| 3224 | - if ( isset( $value->$index_key ) ) { |
|
| 3225 | - $newlist[ $value->$index_key ] = $value->$field; |
|
| 3222 | + foreach ($list as $value) { |
|
| 3223 | + if (is_object($value)) { |
|
| 3224 | + if (isset($value->$index_key)) { |
|
| 3225 | + $newlist[$value->$index_key] = $value->$field; |
|
| 3226 | 3226 | } else { |
| 3227 | 3227 | $newlist[] = $value->$field; |
| 3228 | 3228 | } |
| 3229 | 3229 | } else { |
| 3230 | - if ( isset( $value[ $index_key ] ) ) { |
|
| 3231 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
| 3230 | + if (isset($value[$index_key])) { |
|
| 3231 | + $newlist[$value[$index_key]] = $value[$field]; |
|
| 3232 | 3232 | } else { |
| 3233 | - $newlist[] = $value[ $field ]; |
|
| 3233 | + $newlist[] = $value[$field]; |
|
| 3234 | 3234 | } |
| 3235 | 3235 | } |
| 3236 | 3236 | } |
@@ -3258,13 +3258,13 @@ discard block |
||
| 3258 | 3258 | * @param bool $wp_maybe_load_widgets Whether to load the Widgets library. |
| 3259 | 3259 | * Default true. |
| 3260 | 3260 | */ |
| 3261 | - if ( ! apply_filters( 'load_default_widgets', true ) ) { |
|
| 3261 | + if ( ! apply_filters('load_default_widgets', true)) { |
|
| 3262 | 3262 | return; |
| 3263 | 3263 | } |
| 3264 | 3264 | |
| 3265 | - require_once( ABSPATH . WPINC . '/default-widgets.php' ); |
|
| 3265 | + require_once(ABSPATH.WPINC.'/default-widgets.php'); |
|
| 3266 | 3266 | |
| 3267 | - add_action( '_admin_menu', 'wp_widgets_add_menu' ); |
|
| 3267 | + add_action('_admin_menu', 'wp_widgets_add_menu'); |
|
| 3268 | 3268 | } |
| 3269 | 3269 | |
| 3270 | 3270 | /** |
@@ -3277,11 +3277,11 @@ discard block |
||
| 3277 | 3277 | function wp_widgets_add_menu() { |
| 3278 | 3278 | global $submenu; |
| 3279 | 3279 | |
| 3280 | - if ( ! current_theme_supports( 'widgets' ) ) |
|
| 3280 | + if ( ! current_theme_supports('widgets')) |
|
| 3281 | 3281 | return; |
| 3282 | 3282 | |
| 3283 | - $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); |
|
| 3284 | - ksort( $submenu['themes.php'], SORT_NUMERIC ); |
|
| 3283 | + $submenu['themes.php'][7] = array(__('Widgets'), 'edit_theme_options', 'widgets.php'); |
|
| 3284 | + ksort($submenu['themes.php'], SORT_NUMERIC); |
|
| 3285 | 3285 | } |
| 3286 | 3286 | |
| 3287 | 3287 | /** |
@@ -3293,7 +3293,7 @@ discard block |
||
| 3293 | 3293 | */ |
| 3294 | 3294 | function wp_ob_end_flush_all() { |
| 3295 | 3295 | $levels = ob_get_level(); |
| 3296 | - for ($i=0; $i<$levels; $i++) |
|
| 3296 | + for ($i = 0; $i < $levels; $i++) |
|
| 3297 | 3297 | ob_end_flush(); |
| 3298 | 3298 | } |
| 3299 | 3299 | |
@@ -3321,29 +3321,29 @@ discard block |
||
| 3321 | 3321 | wp_load_translations_early(); |
| 3322 | 3322 | |
| 3323 | 3323 | // Load custom DB error template, if present. |
| 3324 | - if ( file_exists( WP_CONTENT_DIR . '/db-error.php' ) ) { |
|
| 3325 | - require_once( WP_CONTENT_DIR . '/db-error.php' ); |
|
| 3324 | + if (file_exists(WP_CONTENT_DIR.'/db-error.php')) { |
|
| 3325 | + require_once(WP_CONTENT_DIR.'/db-error.php'); |
|
| 3326 | 3326 | die(); |
| 3327 | 3327 | } |
| 3328 | 3328 | |
| 3329 | 3329 | // If installing or in the admin, provide the verbose message. |
| 3330 | - if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) |
|
| 3330 | + if (defined('WP_INSTALLING') || defined('WP_ADMIN')) |
|
| 3331 | 3331 | wp_die($wpdb->error); |
| 3332 | 3332 | |
| 3333 | 3333 | // Otherwise, be terse. |
| 3334 | - status_header( 500 ); |
|
| 3334 | + status_header(500); |
|
| 3335 | 3335 | nocache_headers(); |
| 3336 | - header( 'Content-Type: text/html; charset=utf-8' ); |
|
| 3336 | + header('Content-Type: text/html; charset=utf-8'); |
|
| 3337 | 3337 | ?> |
| 3338 | 3338 | <!DOCTYPE html> |
| 3339 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
| 3339 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if (is_rtl()) echo ' dir="rtl"'; ?>> |
|
| 3340 | 3340 | <head> |
| 3341 | 3341 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 3342 | - <title><?php _e( 'Database Error' ); ?></title> |
|
| 3342 | + <title><?php _e('Database Error'); ?></title> |
|
| 3343 | 3343 | |
| 3344 | 3344 | </head> |
| 3345 | 3345 | <body> |
| 3346 | - <h1><?php _e( 'Error establishing a database connection' ); ?></h1> |
|
| 3346 | + <h1><?php _e('Error establishing a database connection'); ?></h1> |
|
| 3347 | 3347 | </body> |
| 3348 | 3348 | </html> |
| 3349 | 3349 | <?php |
@@ -3358,8 +3358,8 @@ discard block |
||
| 3358 | 3358 | * @param mixed $maybeint Data you wish to have converted to a non-negative integer. |
| 3359 | 3359 | * @return int A non-negative integer. |
| 3360 | 3360 | */ |
| 3361 | -function absint( $maybeint ) { |
|
| 3362 | - return abs( intval( $maybeint ) ); |
|
| 3361 | +function absint($maybeint) { |
|
| 3362 | + return abs(intval($maybeint)); |
|
| 3363 | 3363 | } |
| 3364 | 3364 | |
| 3365 | 3365 | /** |
@@ -3380,7 +3380,7 @@ discard block |
||
| 3380 | 3380 | * @param string $version The version of WordPress that deprecated the function. |
| 3381 | 3381 | * @param string $replacement Optional. The function that should have been called. Default null. |
| 3382 | 3382 | */ |
| 3383 | -function _deprecated_function( $function, $version, $replacement = null ) { |
|
| 3383 | +function _deprecated_function($function, $version, $replacement = null) { |
|
| 3384 | 3384 | |
| 3385 | 3385 | /** |
| 3386 | 3386 | * Fires when a deprecated function is called. |
@@ -3391,7 +3391,7 @@ discard block |
||
| 3391 | 3391 | * @param string $replacement The function that should have been called. |
| 3392 | 3392 | * @param string $version The version of WordPress that deprecated the function. |
| 3393 | 3393 | */ |
| 3394 | - do_action( 'deprecated_function_run', $function, $replacement, $version ); |
|
| 3394 | + do_action('deprecated_function_run', $function, $replacement, $version); |
|
| 3395 | 3395 | |
| 3396 | 3396 | /** |
| 3397 | 3397 | * Filter whether to trigger an error for deprecated functions. |
@@ -3400,17 +3400,17 @@ discard block |
||
| 3400 | 3400 | * |
| 3401 | 3401 | * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
| 3402 | 3402 | */ |
| 3403 | - if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { |
|
| 3404 | - if ( function_exists( '__' ) ) { |
|
| 3405 | - if ( ! is_null( $replacement ) ) |
|
| 3406 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) ); |
|
| 3403 | + if (WP_DEBUG && apply_filters('deprecated_function_trigger_error', true)) { |
|
| 3404 | + if (function_exists('__')) { |
|
| 3405 | + if ( ! is_null($replacement)) |
|
| 3406 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement)); |
|
| 3407 | 3407 | else |
| 3408 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3408 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version)); |
|
| 3409 | 3409 | } else { |
| 3410 | - if ( ! is_null( $replacement ) ) |
|
| 3411 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) ); |
|
| 3410 | + if ( ! is_null($replacement)) |
|
| 3411 | + trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement)); |
|
| 3412 | 3412 | else |
| 3413 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3413 | + trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version)); |
|
| 3414 | 3414 | } |
| 3415 | 3415 | } |
| 3416 | 3416 | } |
@@ -3431,7 +3431,7 @@ discard block |
||
| 3431 | 3431 | * @param string $class The class containing the deprecated constructor. |
| 3432 | 3432 | * @param string $version The version of WordPress that deprecated the function. |
| 3433 | 3433 | */ |
| 3434 | -function _deprecated_constructor( $class, $version ) { |
|
| 3434 | +function _deprecated_constructor($class, $version) { |
|
| 3435 | 3435 | |
| 3436 | 3436 | /** |
| 3437 | 3437 | * Fires when a deprecated constructor is called. |
@@ -3441,7 +3441,7 @@ discard block |
||
| 3441 | 3441 | * @param string $class The class containing the deprecated constructor. |
| 3442 | 3442 | * @param string $version The version of WordPress that deprecated the function. |
| 3443 | 3443 | */ |
| 3444 | - do_action( 'deprecated_constructor_run', $class, $version ); |
|
| 3444 | + do_action('deprecated_constructor_run', $class, $version); |
|
| 3445 | 3445 | |
| 3446 | 3446 | /** |
| 3447 | 3447 | * Filter whether to trigger an error for deprecated functions. |
@@ -3452,11 +3452,11 @@ discard block |
||
| 3452 | 3452 | * |
| 3453 | 3453 | * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
| 3454 | 3454 | */ |
| 3455 | - if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { |
|
| 3456 | - if ( function_exists( '__' ) ) { |
|
| 3457 | - trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $class, $version, '<pre>__construct()</pre>' ) ); |
|
| 3455 | + if (WP_DEBUG && apply_filters('deprecated_constructor_trigger_error', true)) { |
|
| 3456 | + if (function_exists('__')) { |
|
| 3457 | + trigger_error(sprintf(__('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $class, $version, '<pre>__construct()</pre>')); |
|
| 3458 | 3458 | } else { |
| 3459 | - trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class, $version, '<pre>__construct()</pre>' ) ); |
|
| 3459 | + trigger_error(sprintf('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class, $version, '<pre>__construct()</pre>')); |
|
| 3460 | 3460 | } |
| 3461 | 3461 | } |
| 3462 | 3462 | |
@@ -3482,7 +3482,7 @@ discard block |
||
| 3482 | 3482 | * Default null. |
| 3483 | 3483 | * @param string $message Optional. A message regarding the change. Default empty. |
| 3484 | 3484 | */ |
| 3485 | -function _deprecated_file( $file, $version, $replacement = null, $message = '' ) { |
|
| 3485 | +function _deprecated_file($file, $version, $replacement = null, $message = '') { |
|
| 3486 | 3486 | |
| 3487 | 3487 | /** |
| 3488 | 3488 | * Fires when a deprecated file is called. |
@@ -3494,7 +3494,7 @@ discard block |
||
| 3494 | 3494 | * @param string $version The version of WordPress that deprecated the file. |
| 3495 | 3495 | * @param string $message A message regarding the change. |
| 3496 | 3496 | */ |
| 3497 | - do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); |
|
| 3497 | + do_action('deprecated_file_included', $file, $replacement, $version, $message); |
|
| 3498 | 3498 | |
| 3499 | 3499 | /** |
| 3500 | 3500 | * Filter whether to trigger an error for deprecated files. |
@@ -3503,18 +3503,18 @@ discard block |
||
| 3503 | 3503 | * |
| 3504 | 3504 | * @param bool $trigger Whether to trigger the error for deprecated files. Default true. |
| 3505 | 3505 | */ |
| 3506 | - if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { |
|
| 3507 | - $message = empty( $message ) ? '' : ' ' . $message; |
|
| 3508 | - if ( function_exists( '__' ) ) { |
|
| 3509 | - if ( ! is_null( $replacement ) ) |
|
| 3510 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message ); |
|
| 3506 | + if (WP_DEBUG && apply_filters('deprecated_file_trigger_error', true)) { |
|
| 3507 | + $message = empty($message) ? '' : ' '.$message; |
|
| 3508 | + if (function_exists('__')) { |
|
| 3509 | + if ( ! is_null($replacement)) |
|
| 3510 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement).$message); |
|
| 3511 | 3511 | else |
| 3512 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message ); |
|
| 3512 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version).$message); |
|
| 3513 | 3513 | } else { |
| 3514 | - if ( ! is_null( $replacement ) ) |
|
| 3515 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message ); |
|
| 3514 | + if ( ! is_null($replacement)) |
|
| 3515 | + trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement).$message); |
|
| 3516 | 3516 | else |
| 3517 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message ); |
|
| 3517 | + trigger_error(sprintf('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version).$message); |
|
| 3518 | 3518 | } |
| 3519 | 3519 | } |
| 3520 | 3520 | } |
@@ -3544,7 +3544,7 @@ discard block |
||
| 3544 | 3544 | * @param string $version The version of WordPress that deprecated the argument used. |
| 3545 | 3545 | * @param string $message Optional. A message regarding the change. Default null. |
| 3546 | 3546 | */ |
| 3547 | -function _deprecated_argument( $function, $version, $message = null ) { |
|
| 3547 | +function _deprecated_argument($function, $version, $message = null) { |
|
| 3548 | 3548 | |
| 3549 | 3549 | /** |
| 3550 | 3550 | * Fires when a deprecated argument is called. |
@@ -3555,7 +3555,7 @@ discard block |
||
| 3555 | 3555 | * @param string $message A message regarding the change. |
| 3556 | 3556 | * @param string $version The version of WordPress that deprecated the argument used. |
| 3557 | 3557 | */ |
| 3558 | - do_action( 'deprecated_argument_run', $function, $message, $version ); |
|
| 3558 | + do_action('deprecated_argument_run', $function, $message, $version); |
|
| 3559 | 3559 | |
| 3560 | 3560 | /** |
| 3561 | 3561 | * Filter whether to trigger an error for deprecated arguments. |
@@ -3564,17 +3564,17 @@ discard block |
||
| 3564 | 3564 | * |
| 3565 | 3565 | * @param bool $trigger Whether to trigger the error for deprecated arguments. Default true. |
| 3566 | 3566 | */ |
| 3567 | - if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { |
|
| 3568 | - if ( function_exists( '__' ) ) { |
|
| 3569 | - if ( ! is_null( $message ) ) |
|
| 3570 | - trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) ); |
|
| 3567 | + if (WP_DEBUG && apply_filters('deprecated_argument_trigger_error', true)) { |
|
| 3568 | + if (function_exists('__')) { |
|
| 3569 | + if ( ! is_null($message)) |
|
| 3570 | + trigger_error(sprintf(__('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message)); |
|
| 3571 | 3571 | else |
| 3572 | - trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3572 | + trigger_error(sprintf(__('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version)); |
|
| 3573 | 3573 | } else { |
| 3574 | - if ( ! is_null( $message ) ) |
|
| 3575 | - trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) ); |
|
| 3574 | + if ( ! is_null($message)) |
|
| 3575 | + trigger_error(sprintf('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message)); |
|
| 3576 | 3576 | else |
| 3577 | - trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3577 | + trigger_error(sprintf('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version)); |
|
| 3578 | 3578 | } |
| 3579 | 3579 | } |
| 3580 | 3580 | } |
@@ -3595,7 +3595,7 @@ discard block |
||
| 3595 | 3595 | * @param string $message A message explaining what has been done incorrectly. |
| 3596 | 3596 | * @param string $version The version of WordPress where the message was added. |
| 3597 | 3597 | */ |
| 3598 | -function _doing_it_wrong( $function, $message, $version ) { |
|
| 3598 | +function _doing_it_wrong($function, $message, $version) { |
|
| 3599 | 3599 | |
| 3600 | 3600 | /** |
| 3601 | 3601 | * Fires when the given function is being used incorrectly. |
@@ -3606,7 +3606,7 @@ discard block |
||
| 3606 | 3606 | * @param string $message A message explaining what has been done incorrectly. |
| 3607 | 3607 | * @param string $version The version of WordPress where the message was added. |
| 3608 | 3608 | */ |
| 3609 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
| 3609 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
| 3610 | 3610 | |
| 3611 | 3611 | /** |
| 3612 | 3612 | * Filter whether to trigger an error for _doing_it_wrong() calls. |
@@ -3615,15 +3615,15 @@ discard block |
||
| 3615 | 3615 | * |
| 3616 | 3616 | * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true. |
| 3617 | 3617 | */ |
| 3618 | - if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { |
|
| 3619 | - if ( function_exists( '__' ) ) { |
|
| 3620 | - $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); |
|
| 3621 | - $message .= ' ' . __( 'Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.' ); |
|
| 3622 | - trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) ); |
|
| 3618 | + if (WP_DEBUG && apply_filters('doing_it_wrong_trigger_error', true)) { |
|
| 3619 | + if (function_exists('__')) { |
|
| 3620 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s.)'), $version); |
|
| 3621 | + $message .= ' '.__('Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.'); |
|
| 3622 | + trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s'), $function, $message, $version)); |
|
| 3623 | 3623 | } else { |
| 3624 | - $version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version ); |
|
| 3624 | + $version = is_null($version) ? '' : sprintf('(This message was added in version %s.)', $version); |
|
| 3625 | 3625 | $message .= ' Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.'; |
| 3626 | - trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) ); |
|
| 3626 | + trigger_error(sprintf('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version)); |
|
| 3627 | 3627 | } |
| 3628 | 3628 | } |
| 3629 | 3629 | } |
@@ -3636,9 +3636,9 @@ discard block |
||
| 3636 | 3636 | * @return bool Whether the server is running lighttpd < 1.5.0. |
| 3637 | 3637 | */ |
| 3638 | 3638 | function is_lighttpd_before_150() { |
| 3639 | - $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' ); |
|
| 3640 | - $server_parts[1] = isset( $server_parts[1] )? $server_parts[1] : ''; |
|
| 3641 | - return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); |
|
| 3639 | + $server_parts = explode('/', isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : ''); |
|
| 3640 | + $server_parts[1] = isset($server_parts[1]) ? $server_parts[1] : ''; |
|
| 3641 | + return 'lighttpd' == $server_parts[0] && -1 == version_compare($server_parts[1], '1.5.0'); |
|
| 3642 | 3642 | } |
| 3643 | 3643 | |
| 3644 | 3644 | /** |
@@ -3655,18 +3655,18 @@ discard block |
||
| 3655 | 3655 | function apache_mod_loaded($mod, $default = false) { |
| 3656 | 3656 | global $is_apache; |
| 3657 | 3657 | |
| 3658 | - if ( !$is_apache ) |
|
| 3658 | + if ( ! $is_apache) |
|
| 3659 | 3659 | return false; |
| 3660 | 3660 | |
| 3661 | - if ( function_exists( 'apache_get_modules' ) ) { |
|
| 3661 | + if (function_exists('apache_get_modules')) { |
|
| 3662 | 3662 | $mods = apache_get_modules(); |
| 3663 | - if ( in_array($mod, $mods) ) |
|
| 3663 | + if (in_array($mod, $mods)) |
|
| 3664 | 3664 | return true; |
| 3665 | - } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { |
|
| 3665 | + } elseif (function_exists('phpinfo') && false === strpos(ini_get('disable_functions'), 'phpinfo')) { |
|
| 3666 | 3666 | ob_start(); |
| 3667 | 3667 | phpinfo(8); |
| 3668 | 3668 | $phpinfo = ob_get_clean(); |
| 3669 | - if ( false !== strpos($phpinfo, $mod) ) |
|
| 3669 | + if (false !== strpos($phpinfo, $mod)) |
|
| 3670 | 3670 | return true; |
| 3671 | 3671 | } |
| 3672 | 3672 | return $default; |
@@ -3685,7 +3685,7 @@ discard block |
||
| 3685 | 3685 | global $is_iis7; |
| 3686 | 3686 | |
| 3687 | 3687 | $supports_permalinks = false; |
| 3688 | - if ( $is_iis7 ) { |
|
| 3688 | + if ($is_iis7) { |
|
| 3689 | 3689 | /* First we check if the DOMDocument class exists. If it does not exist, then we cannot |
| 3690 | 3690 | * easily update the xml configuration file, hence we just bail out and tell user that |
| 3691 | 3691 | * pretty permalinks cannot be used. |
@@ -3695,7 +3695,7 @@ discard block |
||
| 3695 | 3695 | * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs |
| 3696 | 3696 | * via ISAPI then pretty permalinks will not work. |
| 3697 | 3697 | */ |
| 3698 | - $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' ); |
|
| 3698 | + $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && (PHP_SAPI == 'cgi-fcgi'); |
|
| 3699 | 3699 | } |
| 3700 | 3700 | |
| 3701 | 3701 | /** |
@@ -3705,7 +3705,7 @@ discard block |
||
| 3705 | 3705 | * |
| 3706 | 3706 | * @param bool $supports_permalinks Whether IIS7 supports permalinks. Default false. |
| 3707 | 3707 | */ |
| 3708 | - return apply_filters( 'iis7_supports_permalinks', $supports_permalinks ); |
|
| 3708 | + return apply_filters('iis7_supports_permalinks', $supports_permalinks); |
|
| 3709 | 3709 | } |
| 3710 | 3710 | |
| 3711 | 3711 | /** |
@@ -3722,17 +3722,17 @@ discard block |
||
| 3722 | 3722 | * @param array $allowed_files List of allowed files. |
| 3723 | 3723 | * @return int 0 means nothing is wrong, greater than 0 means something was wrong. |
| 3724 | 3724 | */ |
| 3725 | -function validate_file( $file, $allowed_files = '' ) { |
|
| 3726 | - if ( false !== strpos( $file, '..' ) ) |
|
| 3725 | +function validate_file($file, $allowed_files = '') { |
|
| 3726 | + if (false !== strpos($file, '..')) |
|
| 3727 | 3727 | return 1; |
| 3728 | 3728 | |
| 3729 | - if ( false !== strpos( $file, './' ) ) |
|
| 3729 | + if (false !== strpos($file, './')) |
|
| 3730 | 3730 | return 1; |
| 3731 | 3731 | |
| 3732 | - if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) |
|
| 3732 | + if ( ! empty($allowed_files) && ! in_array($file, $allowed_files)) |
|
| 3733 | 3733 | return 3; |
| 3734 | 3734 | |
| 3735 | - if (':' == substr( $file, 1, 1 ) ) |
|
| 3735 | + if (':' == substr($file, 1, 1)) |
|
| 3736 | 3736 | return 2; |
| 3737 | 3737 | |
| 3738 | 3738 | return 0; |
@@ -3746,12 +3746,12 @@ discard block |
||
| 3746 | 3746 | * @return bool True if SSL, false if not used. |
| 3747 | 3747 | */ |
| 3748 | 3748 | function is_ssl() { |
| 3749 | - if ( isset($_SERVER['HTTPS']) ) { |
|
| 3750 | - if ( 'on' == strtolower($_SERVER['HTTPS']) ) |
|
| 3749 | + if (isset($_SERVER['HTTPS'])) { |
|
| 3750 | + if ('on' == strtolower($_SERVER['HTTPS'])) |
|
| 3751 | 3751 | return true; |
| 3752 | - if ( '1' == $_SERVER['HTTPS'] ) |
|
| 3752 | + if ('1' == $_SERVER['HTTPS']) |
|
| 3753 | 3753 | return true; |
| 3754 | - } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { |
|
| 3754 | + } elseif (isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'])) { |
|
| 3755 | 3755 | return true; |
| 3756 | 3756 | } |
| 3757 | 3757 | return false; |
@@ -3767,8 +3767,8 @@ discard block |
||
| 3767 | 3767 | * @param string|bool $force Optional Whether to force SSL login. Default null. |
| 3768 | 3768 | * @return bool True if forced, false if not forced. |
| 3769 | 3769 | */ |
| 3770 | -function force_ssl_login( $force = null ) { |
|
| 3771 | - return force_ssl_admin( $force ); |
|
| 3770 | +function force_ssl_login($force = null) { |
|
| 3771 | + return force_ssl_admin($force); |
|
| 3772 | 3772 | } |
| 3773 | 3773 | |
| 3774 | 3774 | /** |
@@ -3781,10 +3781,10 @@ discard block |
||
| 3781 | 3781 | * @param string|bool $force Optional. Whether to force SSL in admin screens. Default null. |
| 3782 | 3782 | * @return bool True if forced, false if not forced. |
| 3783 | 3783 | */ |
| 3784 | -function force_ssl_admin( $force = null ) { |
|
| 3784 | +function force_ssl_admin($force = null) { |
|
| 3785 | 3785 | static $forced = false; |
| 3786 | 3786 | |
| 3787 | - if ( !is_null( $force ) ) { |
|
| 3787 | + if ( ! is_null($force)) { |
|
| 3788 | 3788 | $old_forced = $forced; |
| 3789 | 3789 | $forced = $force; |
| 3790 | 3790 | return $old_forced; |
@@ -3804,39 +3804,39 @@ discard block |
||
| 3804 | 3804 | * @return string The guessed URL. |
| 3805 | 3805 | */ |
| 3806 | 3806 | function wp_guess_url() { |
| 3807 | - if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { |
|
| 3807 | + if (defined('WP_SITEURL') && '' != WP_SITEURL) { |
|
| 3808 | 3808 | $url = WP_SITEURL; |
| 3809 | 3809 | } else { |
| 3810 | - $abspath_fix = str_replace( '\\', '/', ABSPATH ); |
|
| 3811 | - $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); |
|
| 3810 | + $abspath_fix = str_replace('\\', '/', ABSPATH); |
|
| 3811 | + $script_filename_dir = dirname($_SERVER['SCRIPT_FILENAME']); |
|
| 3812 | 3812 | |
| 3813 | 3813 | // The request is for the admin |
| 3814 | - if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { |
|
| 3815 | - $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); |
|
| 3814 | + if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') !== false || strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false) { |
|
| 3815 | + $path = preg_replace('#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI']); |
|
| 3816 | 3816 | |
| 3817 | 3817 | // The request is for a file in ABSPATH |
| 3818 | - } elseif ( $script_filename_dir . '/' == $abspath_fix ) { |
|
| 3818 | + } elseif ($script_filename_dir.'/' == $abspath_fix) { |
|
| 3819 | 3819 | // Strip off any file/query params in the path |
| 3820 | - $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); |
|
| 3820 | + $path = preg_replace('#/[^/]*$#i', '', $_SERVER['PHP_SELF']); |
|
| 3821 | 3821 | |
| 3822 | 3822 | } else { |
| 3823 | - if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) { |
|
| 3823 | + if (false !== strpos($_SERVER['SCRIPT_FILENAME'], $abspath_fix)) { |
|
| 3824 | 3824 | // Request is hitting a file inside ABSPATH |
| 3825 | - $directory = str_replace( ABSPATH, '', $script_filename_dir ); |
|
| 3825 | + $directory = str_replace(ABSPATH, '', $script_filename_dir); |
|
| 3826 | 3826 | // Strip off the sub directory, and any file/query params |
| 3827 | - $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ); |
|
| 3828 | - } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { |
|
| 3827 | + $path = preg_replace('#/'.preg_quote($directory, '#').'/[^/]*$#i', '', $_SERVER['REQUEST_URI']); |
|
| 3828 | + } elseif (false !== strpos($abspath_fix, $script_filename_dir)) { |
|
| 3829 | 3829 | // Request is hitting a file above ABSPATH |
| 3830 | - $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); |
|
| 3830 | + $subdirectory = substr($abspath_fix, strpos($abspath_fix, $script_filename_dir) + strlen($script_filename_dir)); |
|
| 3831 | 3831 | // Strip off any file/query params from the path, appending the sub directory to the install |
| 3832 | - $path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory; |
|
| 3832 | + $path = preg_replace('#/[^/]*$#i', '', $_SERVER['REQUEST_URI']).$subdirectory; |
|
| 3833 | 3833 | } else { |
| 3834 | 3834 | $path = $_SERVER['REQUEST_URI']; |
| 3835 | 3835 | } |
| 3836 | 3836 | } |
| 3837 | 3837 | |
| 3838 | 3838 | $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet |
| 3839 | - $url = $schema . $_SERVER['HTTP_HOST'] . $path; |
|
| 3839 | + $url = $schema.$_SERVER['HTTP_HOST'].$path; |
|
| 3840 | 3840 | } |
| 3841 | 3841 | |
| 3842 | 3842 | return rtrim($url, '/'); |
@@ -3859,10 +3859,10 @@ discard block |
||
| 3859 | 3859 | * @param bool $suspend Optional. Suspends additions if true, re-enables them if false. |
| 3860 | 3860 | * @return bool The current suspend setting |
| 3861 | 3861 | */ |
| 3862 | -function wp_suspend_cache_addition( $suspend = null ) { |
|
| 3862 | +function wp_suspend_cache_addition($suspend = null) { |
|
| 3863 | 3863 | static $_suspend = false; |
| 3864 | 3864 | |
| 3865 | - if ( is_bool( $suspend ) ) |
|
| 3865 | + if (is_bool($suspend)) |
|
| 3866 | 3866 | $_suspend = $suspend; |
| 3867 | 3867 | |
| 3868 | 3868 | return $_suspend; |
@@ -3882,7 +3882,7 @@ discard block |
||
| 3882 | 3882 | * @param bool $suspend Optional. Whether to suspend or enable cache invalidation. Default true. |
| 3883 | 3883 | * @return bool The current suspend setting. |
| 3884 | 3884 | */ |
| 3885 | -function wp_suspend_cache_invalidation( $suspend = true ) { |
|
| 3885 | +function wp_suspend_cache_invalidation($suspend = true) { |
|
| 3886 | 3886 | global $_wp_suspend_cache_invalidation; |
| 3887 | 3887 | |
| 3888 | 3888 | $current_suspend = $_wp_suspend_cache_invalidation; |
@@ -3902,14 +3902,14 @@ discard block |
||
| 3902 | 3902 | * @return bool True if $site_id is the main site of the network, or if not |
| 3903 | 3903 | * running Multisite. |
| 3904 | 3904 | */ |
| 3905 | -function is_main_site( $site_id = null ) { |
|
| 3905 | +function is_main_site($site_id = null) { |
|
| 3906 | 3906 | // This is the current network's information; 'site' is old terminology. |
| 3907 | 3907 | global $current_site; |
| 3908 | 3908 | |
| 3909 | - if ( ! is_multisite() ) |
|
| 3909 | + if ( ! is_multisite()) |
|
| 3910 | 3910 | return true; |
| 3911 | 3911 | |
| 3912 | - if ( ! $site_id ) |
|
| 3912 | + if ( ! $site_id) |
|
| 3913 | 3913 | $site_id = get_current_blog_id(); |
| 3914 | 3914 | |
| 3915 | 3915 | return (int) $site_id === (int) $current_site->blog_id; |
@@ -3923,20 +3923,20 @@ discard block |
||
| 3923 | 3923 | * @param int $network_id Optional. Network ID to test. Defaults to current network. |
| 3924 | 3924 | * @return bool True if $network_id is the main network, or if not running Multisite. |
| 3925 | 3925 | */ |
| 3926 | -function is_main_network( $network_id = null ) { |
|
| 3927 | - if ( ! is_multisite() ) { |
|
| 3926 | +function is_main_network($network_id = null) { |
|
| 3927 | + if ( ! is_multisite()) { |
|
| 3928 | 3928 | return true; |
| 3929 | 3929 | } |
| 3930 | 3930 | |
| 3931 | 3931 | $current_network_id = (int) get_current_site()->id; |
| 3932 | 3932 | |
| 3933 | - if ( null === $network_id ) { |
|
| 3933 | + if (null === $network_id) { |
|
| 3934 | 3934 | $network_id = $current_network_id; |
| 3935 | 3935 | } |
| 3936 | 3936 | |
| 3937 | 3937 | $network_id = (int) $network_id; |
| 3938 | 3938 | |
| 3939 | - return ( $network_id === get_main_network_id() ); |
|
| 3939 | + return ($network_id === get_main_network_id()); |
|
| 3940 | 3940 | } |
| 3941 | 3941 | |
| 3942 | 3942 | /** |
@@ -3951,21 +3951,21 @@ discard block |
||
| 3951 | 3951 | function get_main_network_id() { |
| 3952 | 3952 | global $wpdb; |
| 3953 | 3953 | |
| 3954 | - if ( ! is_multisite() ) { |
|
| 3954 | + if ( ! is_multisite()) { |
|
| 3955 | 3955 | return 1; |
| 3956 | 3956 | } |
| 3957 | 3957 | |
| 3958 | - if ( defined( 'PRIMARY_NETWORK_ID' ) ) { |
|
| 3958 | + if (defined('PRIMARY_NETWORK_ID')) { |
|
| 3959 | 3959 | $main_network_id = PRIMARY_NETWORK_ID; |
| 3960 | - } elseif ( 1 === (int) get_current_site()->id ) { |
|
| 3960 | + } elseif (1 === (int) get_current_site()->id) { |
|
| 3961 | 3961 | // If the current network has an ID of 1, assume it is the main network. |
| 3962 | 3962 | $main_network_id = 1; |
| 3963 | 3963 | } else { |
| 3964 | - $main_network_id = wp_cache_get( 'primary_network_id', 'site-options' ); |
|
| 3964 | + $main_network_id = wp_cache_get('primary_network_id', 'site-options'); |
|
| 3965 | 3965 | |
| 3966 | - if ( false === $main_network_id ) { |
|
| 3967 | - $main_network_id = (int) $wpdb->get_var( "SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1" ); |
|
| 3968 | - wp_cache_add( 'primary_network_id', $main_network_id, 'site-options' ); |
|
| 3966 | + if (false === $main_network_id) { |
|
| 3967 | + $main_network_id = (int) $wpdb->get_var("SELECT id FROM {$wpdb->site} ORDER BY id LIMIT 1"); |
|
| 3968 | + wp_cache_add('primary_network_id', $main_network_id, 'site-options'); |
|
| 3969 | 3969 | } |
| 3970 | 3970 | } |
| 3971 | 3971 | |
@@ -3976,7 +3976,7 @@ discard block |
||
| 3976 | 3976 | * |
| 3977 | 3977 | * @param int $main_network_id The ID of the main network. |
| 3978 | 3978 | */ |
| 3979 | - return (int) apply_filters( 'get_main_network_id', $main_network_id ); |
|
| 3979 | + return (int) apply_filters('get_main_network_id', $main_network_id); |
|
| 3980 | 3980 | } |
| 3981 | 3981 | |
| 3982 | 3982 | /** |
@@ -3989,11 +3989,11 @@ discard block |
||
| 3989 | 3989 | * @return bool True if multisite and global terms enabled. |
| 3990 | 3990 | */ |
| 3991 | 3991 | function global_terms_enabled() { |
| 3992 | - if ( ! is_multisite() ) |
|
| 3992 | + if ( ! is_multisite()) |
|
| 3993 | 3993 | return false; |
| 3994 | 3994 | |
| 3995 | 3995 | static $global_terms = null; |
| 3996 | - if ( is_null( $global_terms ) ) { |
|
| 3996 | + if (is_null($global_terms)) { |
|
| 3997 | 3997 | |
| 3998 | 3998 | /** |
| 3999 | 3999 | * Filter whether global terms are enabled. |
@@ -4005,11 +4005,11 @@ discard block |
||
| 4005 | 4005 | * |
| 4006 | 4006 | * @param null $enabled Whether global terms are enabled. |
| 4007 | 4007 | */ |
| 4008 | - $filter = apply_filters( 'global_terms_enabled', null ); |
|
| 4009 | - if ( ! is_null( $filter ) ) |
|
| 4008 | + $filter = apply_filters('global_terms_enabled', null); |
|
| 4009 | + if ( ! is_null($filter)) |
|
| 4010 | 4010 | $global_terms = (bool) $filter; |
| 4011 | 4011 | else |
| 4012 | - $global_terms = (bool) get_site_option( 'global_terms_enabled', false ); |
|
| 4012 | + $global_terms = (bool) get_site_option('global_terms_enabled', false); |
|
| 4013 | 4013 | } |
| 4014 | 4014 | return $global_terms; |
| 4015 | 4015 | } |
@@ -4024,16 +4024,16 @@ discard block |
||
| 4024 | 4024 | * @return float|false Timezone GMT offset, false otherwise. |
| 4025 | 4025 | */ |
| 4026 | 4026 | function wp_timezone_override_offset() { |
| 4027 | - if ( !$timezone_string = get_option( 'timezone_string' ) ) { |
|
| 4027 | + if ( ! $timezone_string = get_option('timezone_string')) { |
|
| 4028 | 4028 | return false; |
| 4029 | 4029 | } |
| 4030 | 4030 | |
| 4031 | - $timezone_object = timezone_open( $timezone_string ); |
|
| 4031 | + $timezone_object = timezone_open($timezone_string); |
|
| 4032 | 4032 | $datetime_object = date_create(); |
| 4033 | - if ( false === $timezone_object || false === $datetime_object ) { |
|
| 4033 | + if (false === $timezone_object || false === $datetime_object) { |
|
| 4034 | 4034 | return false; |
| 4035 | 4035 | } |
| 4036 | - return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 ); |
|
| 4036 | + return round(timezone_offset_get($timezone_object, $datetime_object) / HOUR_IN_SECONDS, 2); |
|
| 4037 | 4037 | } |
| 4038 | 4038 | |
| 4039 | 4039 | /** |
@@ -4046,41 +4046,41 @@ discard block |
||
| 4046 | 4046 | * @param array $b |
| 4047 | 4047 | * @return int |
| 4048 | 4048 | */ |
| 4049 | -function _wp_timezone_choice_usort_callback( $a, $b ) { |
|
| 4049 | +function _wp_timezone_choice_usort_callback($a, $b) { |
|
| 4050 | 4050 | // Don't use translated versions of Etc |
| 4051 | - if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) { |
|
| 4051 | + if ('Etc' === $a['continent'] && 'Etc' === $b['continent']) { |
|
| 4052 | 4052 | // Make the order of these more like the old dropdown |
| 4053 | - if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) { |
|
| 4054 | - return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) ); |
|
| 4053 | + if ('GMT+' === substr($a['city'], 0, 4) && 'GMT+' === substr($b['city'], 0, 4)) { |
|
| 4054 | + return -1 * (strnatcasecmp($a['city'], $b['city'])); |
|
| 4055 | 4055 | } |
| 4056 | - if ( 'UTC' === $a['city'] ) { |
|
| 4057 | - if ( 'GMT+' === substr( $b['city'], 0, 4 ) ) { |
|
| 4056 | + if ('UTC' === $a['city']) { |
|
| 4057 | + if ('GMT+' === substr($b['city'], 0, 4)) { |
|
| 4058 | 4058 | return 1; |
| 4059 | 4059 | } |
| 4060 | 4060 | return -1; |
| 4061 | 4061 | } |
| 4062 | - if ( 'UTC' === $b['city'] ) { |
|
| 4063 | - if ( 'GMT+' === substr( $a['city'], 0, 4 ) ) { |
|
| 4062 | + if ('UTC' === $b['city']) { |
|
| 4063 | + if ('GMT+' === substr($a['city'], 0, 4)) { |
|
| 4064 | 4064 | return -1; |
| 4065 | 4065 | } |
| 4066 | 4066 | return 1; |
| 4067 | 4067 | } |
| 4068 | - return strnatcasecmp( $a['city'], $b['city'] ); |
|
| 4068 | + return strnatcasecmp($a['city'], $b['city']); |
|
| 4069 | 4069 | } |
| 4070 | - if ( $a['t_continent'] == $b['t_continent'] ) { |
|
| 4071 | - if ( $a['t_city'] == $b['t_city'] ) { |
|
| 4072 | - return strnatcasecmp( $a['t_subcity'], $b['t_subcity'] ); |
|
| 4070 | + if ($a['t_continent'] == $b['t_continent']) { |
|
| 4071 | + if ($a['t_city'] == $b['t_city']) { |
|
| 4072 | + return strnatcasecmp($a['t_subcity'], $b['t_subcity']); |
|
| 4073 | 4073 | } |
| 4074 | - return strnatcasecmp( $a['t_city'], $b['t_city'] ); |
|
| 4074 | + return strnatcasecmp($a['t_city'], $b['t_city']); |
|
| 4075 | 4075 | } else { |
| 4076 | 4076 | // Force Etc to the bottom of the list |
| 4077 | - if ( 'Etc' === $a['continent'] ) { |
|
| 4077 | + if ('Etc' === $a['continent']) { |
|
| 4078 | 4078 | return 1; |
| 4079 | 4079 | } |
| 4080 | - if ( 'Etc' === $b['continent'] ) { |
|
| 4080 | + if ('Etc' === $b['continent']) { |
|
| 4081 | 4081 | return -1; |
| 4082 | 4082 | } |
| 4083 | - return strnatcasecmp( $a['t_continent'], $b['t_continent'] ); |
|
| 4083 | + return strnatcasecmp($a['t_continent'], $b['t_continent']); |
|
| 4084 | 4084 | } |
| 4085 | 4085 | } |
| 4086 | 4086 | |
@@ -4094,125 +4094,125 @@ discard block |
||
| 4094 | 4094 | * @param string $selected_zone Selected timezone. |
| 4095 | 4095 | * @return string |
| 4096 | 4096 | */ |
| 4097 | -function wp_timezone_choice( $selected_zone ) { |
|
| 4097 | +function wp_timezone_choice($selected_zone) { |
|
| 4098 | 4098 | static $mo_loaded = false; |
| 4099 | 4099 | |
| 4100 | - $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'); |
|
| 4100 | + $continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'); |
|
| 4101 | 4101 | |
| 4102 | 4102 | // Load translations for continents and cities |
| 4103 | - if ( !$mo_loaded ) { |
|
| 4103 | + if ( ! $mo_loaded) { |
|
| 4104 | 4104 | $locale = get_locale(); |
| 4105 | - $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo'; |
|
| 4106 | - load_textdomain( 'continents-cities', $mofile ); |
|
| 4105 | + $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo'; |
|
| 4106 | + load_textdomain('continents-cities', $mofile); |
|
| 4107 | 4107 | $mo_loaded = true; |
| 4108 | 4108 | } |
| 4109 | 4109 | |
| 4110 | 4110 | $zonen = array(); |
| 4111 | - foreach ( timezone_identifiers_list() as $zone ) { |
|
| 4112 | - $zone = explode( '/', $zone ); |
|
| 4113 | - if ( !in_array( $zone[0], $continents ) ) { |
|
| 4111 | + foreach (timezone_identifiers_list() as $zone) { |
|
| 4112 | + $zone = explode('/', $zone); |
|
| 4113 | + if ( ! in_array($zone[0], $continents)) { |
|
| 4114 | 4114 | continue; |
| 4115 | 4115 | } |
| 4116 | 4116 | |
| 4117 | 4117 | // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later |
| 4118 | 4118 | $exists = array( |
| 4119 | - 0 => ( isset( $zone[0] ) && $zone[0] ), |
|
| 4120 | - 1 => ( isset( $zone[1] ) && $zone[1] ), |
|
| 4121 | - 2 => ( isset( $zone[2] ) && $zone[2] ), |
|
| 4119 | + 0 => (isset($zone[0]) && $zone[0]), |
|
| 4120 | + 1 => (isset($zone[1]) && $zone[1]), |
|
| 4121 | + 2 => (isset($zone[2]) && $zone[2]), |
|
| 4122 | 4122 | ); |
| 4123 | - $exists[3] = ( $exists[0] && 'Etc' !== $zone[0] ); |
|
| 4124 | - $exists[4] = ( $exists[1] && $exists[3] ); |
|
| 4125 | - $exists[5] = ( $exists[2] && $exists[3] ); |
|
| 4123 | + $exists[3] = ($exists[0] && 'Etc' !== $zone[0]); |
|
| 4124 | + $exists[4] = ($exists[1] && $exists[3]); |
|
| 4125 | + $exists[5] = ($exists[2] && $exists[3]); |
|
| 4126 | 4126 | |
| 4127 | 4127 | $zonen[] = array( |
| 4128 | - 'continent' => ( $exists[0] ? $zone[0] : '' ), |
|
| 4129 | - 'city' => ( $exists[1] ? $zone[1] : '' ), |
|
| 4130 | - 'subcity' => ( $exists[2] ? $zone[2] : '' ), |
|
| 4131 | - 't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ), |
|
| 4132 | - 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), |
|
| 4133 | - 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ) |
|
| 4128 | + 'continent' => ($exists[0] ? $zone[0] : ''), |
|
| 4129 | + 'city' => ($exists[1] ? $zone[1] : ''), |
|
| 4130 | + 'subcity' => ($exists[2] ? $zone[2] : ''), |
|
| 4131 | + 't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''), |
|
| 4132 | + 't_city' => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''), |
|
| 4133 | + 't_subcity' => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : '') |
|
| 4134 | 4134 | ); |
| 4135 | 4135 | } |
| 4136 | - usort( $zonen, '_wp_timezone_choice_usort_callback' ); |
|
| 4136 | + usort($zonen, '_wp_timezone_choice_usort_callback'); |
|
| 4137 | 4137 | |
| 4138 | 4138 | $structure = array(); |
| 4139 | 4139 | |
| 4140 | - if ( empty( $selected_zone ) ) { |
|
| 4141 | - $structure[] = '<option selected="selected" value="">' . __( 'Select a city' ) . '</option>'; |
|
| 4140 | + if (empty($selected_zone)) { |
|
| 4141 | + $structure[] = '<option selected="selected" value="">'.__('Select a city').'</option>'; |
|
| 4142 | 4142 | } |
| 4143 | 4143 | |
| 4144 | - foreach ( $zonen as $key => $zone ) { |
|
| 4144 | + foreach ($zonen as $key => $zone) { |
|
| 4145 | 4145 | // Build value in an array to join later |
| 4146 | - $value = array( $zone['continent'] ); |
|
| 4146 | + $value = array($zone['continent']); |
|
| 4147 | 4147 | |
| 4148 | - if ( empty( $zone['city'] ) ) { |
|
| 4148 | + if (empty($zone['city'])) { |
|
| 4149 | 4149 | // It's at the continent level (generally won't happen) |
| 4150 | 4150 | $display = $zone['t_continent']; |
| 4151 | 4151 | } else { |
| 4152 | 4152 | // It's inside a continent group |
| 4153 | 4153 | |
| 4154 | 4154 | // Continent optgroup |
| 4155 | - if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) { |
|
| 4155 | + if ( ! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) { |
|
| 4156 | 4156 | $label = $zone['t_continent']; |
| 4157 | - $structure[] = '<optgroup label="'. esc_attr( $label ) .'">'; |
|
| 4157 | + $structure[] = '<optgroup label="'.esc_attr($label).'">'; |
|
| 4158 | 4158 | } |
| 4159 | 4159 | |
| 4160 | 4160 | // Add the city to the value |
| 4161 | 4161 | $value[] = $zone['city']; |
| 4162 | 4162 | |
| 4163 | 4163 | $display = $zone['t_city']; |
| 4164 | - if ( !empty( $zone['subcity'] ) ) { |
|
| 4164 | + if ( ! empty($zone['subcity'])) { |
|
| 4165 | 4165 | // Add the subcity to the value |
| 4166 | 4166 | $value[] = $zone['subcity']; |
| 4167 | - $display .= ' - ' . $zone['t_subcity']; |
|
| 4167 | + $display .= ' - '.$zone['t_subcity']; |
|
| 4168 | 4168 | } |
| 4169 | 4169 | } |
| 4170 | 4170 | |
| 4171 | 4171 | // Build the value |
| 4172 | - $value = join( '/', $value ); |
|
| 4172 | + $value = join('/', $value); |
|
| 4173 | 4173 | $selected = ''; |
| 4174 | - if ( $value === $selected_zone ) { |
|
| 4174 | + if ($value === $selected_zone) { |
|
| 4175 | 4175 | $selected = 'selected="selected" '; |
| 4176 | 4176 | } |
| 4177 | - $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>"; |
|
| 4177 | + $structure[] = '<option '.$selected.'value="'.esc_attr($value).'">'.esc_html($display)."</option>"; |
|
| 4178 | 4178 | |
| 4179 | 4179 | // Close continent optgroup |
| 4180 | - if ( !empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) { |
|
| 4180 | + if ( ! empty($zone['city']) && ( ! isset($zonen[$key + 1]) || (isset($zonen[$key + 1]) && $zonen[$key + 1]['continent'] !== $zone['continent']))) { |
|
| 4181 | 4181 | $structure[] = '</optgroup>'; |
| 4182 | 4182 | } |
| 4183 | 4183 | } |
| 4184 | 4184 | |
| 4185 | 4185 | // Do UTC |
| 4186 | - $structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">'; |
|
| 4186 | + $structure[] = '<optgroup label="'.esc_attr__('UTC').'">'; |
|
| 4187 | 4187 | $selected = ''; |
| 4188 | - if ( 'UTC' === $selected_zone ) |
|
| 4188 | + if ('UTC' === $selected_zone) |
|
| 4189 | 4189 | $selected = 'selected="selected" '; |
| 4190 | - $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>'; |
|
| 4190 | + $structure[] = '<option '.$selected.'value="'.esc_attr('UTC').'">'.__('UTC').'</option>'; |
|
| 4191 | 4191 | $structure[] = '</optgroup>'; |
| 4192 | 4192 | |
| 4193 | 4193 | // Do manual UTC offsets |
| 4194 | - $structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">'; |
|
| 4195 | - $offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, |
|
| 4194 | + $structure[] = '<optgroup label="'.esc_attr__('Manual Offsets').'">'; |
|
| 4195 | + $offset_range = array(-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, |
|
| 4196 | 4196 | 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14); |
| 4197 | - foreach ( $offset_range as $offset ) { |
|
| 4198 | - if ( 0 <= $offset ) |
|
| 4199 | - $offset_name = '+' . $offset; |
|
| 4197 | + foreach ($offset_range as $offset) { |
|
| 4198 | + if (0 <= $offset) |
|
| 4199 | + $offset_name = '+'.$offset; |
|
| 4200 | 4200 | else |
| 4201 | 4201 | $offset_name = (string) $offset; |
| 4202 | 4202 | |
| 4203 | 4203 | $offset_value = $offset_name; |
| 4204 | - $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name); |
|
| 4205 | - $offset_name = 'UTC' . $offset_name; |
|
| 4206 | - $offset_value = 'UTC' . $offset_value; |
|
| 4204 | + $offset_name = str_replace(array('.25', '.5', '.75'), array(':15', ':30', ':45'), $offset_name); |
|
| 4205 | + $offset_name = 'UTC'.$offset_name; |
|
| 4206 | + $offset_value = 'UTC'.$offset_value; |
|
| 4207 | 4207 | $selected = ''; |
| 4208 | - if ( $offset_value === $selected_zone ) |
|
| 4208 | + if ($offset_value === $selected_zone) |
|
| 4209 | 4209 | $selected = 'selected="selected" '; |
| 4210 | - $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>"; |
|
| 4210 | + $structure[] = '<option '.$selected.'value="'.esc_attr($offset_value).'">'.esc_html($offset_name)."</option>"; |
|
| 4211 | 4211 | |
| 4212 | 4212 | } |
| 4213 | 4213 | $structure[] = '</optgroup>'; |
| 4214 | 4214 | |
| 4215 | - return join( "\n", $structure ); |
|
| 4215 | + return join("\n", $structure); |
|
| 4216 | 4216 | } |
| 4217 | 4217 | |
| 4218 | 4218 | /** |
@@ -4226,7 +4226,7 @@ discard block |
||
| 4226 | 4226 | * @param string $str Header comment to clean up. |
| 4227 | 4227 | * @return string |
| 4228 | 4228 | */ |
| 4229 | -function _cleanup_header_comment( $str ) { |
|
| 4229 | +function _cleanup_header_comment($str) { |
|
| 4230 | 4230 | return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str)); |
| 4231 | 4231 | } |
| 4232 | 4232 | |
@@ -4243,18 +4243,18 @@ discard block |
||
| 4243 | 4243 | function wp_scheduled_delete() { |
| 4244 | 4244 | global $wpdb; |
| 4245 | 4245 | |
| 4246 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
| 4246 | + $delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS); |
|
| 4247 | 4247 | |
| 4248 | 4248 | $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); |
| 4249 | 4249 | |
| 4250 | - foreach ( (array) $posts_to_delete as $post ) { |
|
| 4250 | + foreach ((array) $posts_to_delete as $post) { |
|
| 4251 | 4251 | $post_id = (int) $post['post_id']; |
| 4252 | - if ( !$post_id ) |
|
| 4252 | + if ( ! $post_id) |
|
| 4253 | 4253 | continue; |
| 4254 | 4254 | |
| 4255 | 4255 | $del_post = get_post($post_id); |
| 4256 | 4256 | |
| 4257 | - if ( !$del_post || 'trash' != $del_post->post_status ) { |
|
| 4257 | + if ( ! $del_post || 'trash' != $del_post->post_status) { |
|
| 4258 | 4258 | delete_post_meta($post_id, '_wp_trash_meta_status'); |
| 4259 | 4259 | delete_post_meta($post_id, '_wp_trash_meta_time'); |
| 4260 | 4260 | } else { |
@@ -4264,14 +4264,14 @@ discard block |
||
| 4264 | 4264 | |
| 4265 | 4265 | $comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); |
| 4266 | 4266 | |
| 4267 | - foreach ( (array) $comments_to_delete as $comment ) { |
|
| 4267 | + foreach ((array) $comments_to_delete as $comment) { |
|
| 4268 | 4268 | $comment_id = (int) $comment['comment_id']; |
| 4269 | - if ( !$comment_id ) |
|
| 4269 | + if ( ! $comment_id) |
|
| 4270 | 4270 | continue; |
| 4271 | 4271 | |
| 4272 | 4272 | $del_comment = get_comment($comment_id); |
| 4273 | 4273 | |
| 4274 | - if ( !$del_comment || 'trash' != $del_comment->comment_approved ) { |
|
| 4274 | + if ( ! $del_comment || 'trash' != $del_comment->comment_approved) { |
|
| 4275 | 4275 | delete_comment_meta($comment_id, '_wp_trash_meta_time'); |
| 4276 | 4276 | delete_comment_meta($comment_id, '_wp_trash_meta_status'); |
| 4277 | 4277 | } else { |
@@ -4300,18 +4300,18 @@ discard block |
||
| 4300 | 4300 | * Default empty. |
| 4301 | 4301 | * @return array Array of file headers in `HeaderKey => Header Value` format. |
| 4302 | 4302 | */ |
| 4303 | -function get_file_data( $file, $default_headers, $context = '' ) { |
|
| 4303 | +function get_file_data($file, $default_headers, $context = '') { |
|
| 4304 | 4304 | // We don't need to write to the file, so just open for reading. |
| 4305 | - $fp = fopen( $file, 'r' ); |
|
| 4305 | + $fp = fopen($file, 'r'); |
|
| 4306 | 4306 | |
| 4307 | 4307 | // Pull only the first 8kiB of the file in. |
| 4308 | - $file_data = fread( $fp, 8192 ); |
|
| 4308 | + $file_data = fread($fp, 8192); |
|
| 4309 | 4309 | |
| 4310 | 4310 | // PHP will close file handle, but we are good citizens. |
| 4311 | - fclose( $fp ); |
|
| 4311 | + fclose($fp); |
|
| 4312 | 4312 | |
| 4313 | 4313 | // Make sure we catch CR-only line endings. |
| 4314 | - $file_data = str_replace( "\r", "\n", $file_data ); |
|
| 4314 | + $file_data = str_replace("\r", "\n", $file_data); |
|
| 4315 | 4315 | |
| 4316 | 4316 | /** |
| 4317 | 4317 | * Filter extra file headers by context. |
@@ -4323,18 +4323,18 @@ discard block |
||
| 4323 | 4323 | * |
| 4324 | 4324 | * @param array $extra_context_headers Empty array by default. |
| 4325 | 4325 | */ |
| 4326 | - if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) { |
|
| 4327 | - $extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values |
|
| 4328 | - $all_headers = array_merge( $extra_headers, (array) $default_headers ); |
|
| 4326 | + if ($context && $extra_headers = apply_filters("extra_{$context}_headers", array())) { |
|
| 4327 | + $extra_headers = array_combine($extra_headers, $extra_headers); // keys equal values |
|
| 4328 | + $all_headers = array_merge($extra_headers, (array) $default_headers); |
|
| 4329 | 4329 | } else { |
| 4330 | 4330 | $all_headers = $default_headers; |
| 4331 | 4331 | } |
| 4332 | 4332 | |
| 4333 | - foreach ( $all_headers as $field => $regex ) { |
|
| 4334 | - if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) |
|
| 4335 | - $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
|
| 4333 | + foreach ($all_headers as $field => $regex) { |
|
| 4334 | + if (preg_match('/^[ \t\/*#@]*'.preg_quote($regex, '/').':(.*)$/mi', $file_data, $match) && $match[1]) |
|
| 4335 | + $all_headers[$field] = _cleanup_header_comment($match[1]); |
|
| 4336 | 4336 | else |
| 4337 | - $all_headers[ $field ] = ''; |
|
| 4337 | + $all_headers[$field] = ''; |
|
| 4338 | 4338 | } |
| 4339 | 4339 | |
| 4340 | 4340 | return $all_headers; |
@@ -4433,7 +4433,7 @@ discard block |
||
| 4433 | 4433 | * @see http://src.chromium.org/viewvc/chrome?view=rev&revision=6985 |
| 4434 | 4434 | */ |
| 4435 | 4435 | function send_nosniff_header() { |
| 4436 | - @header( 'X-Content-Type-Options: nosniff' ); |
|
| 4436 | + @header('X-Content-Type-Options: nosniff'); |
|
| 4437 | 4437 | } |
| 4438 | 4438 | |
| 4439 | 4439 | /** |
@@ -4445,8 +4445,8 @@ discard block |
||
| 4445 | 4445 | * @param string $column Database column. |
| 4446 | 4446 | * @return string SQL clause. |
| 4447 | 4447 | */ |
| 4448 | -function _wp_mysql_week( $column ) { |
|
| 4449 | - switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { |
|
| 4448 | +function _wp_mysql_week($column) { |
|
| 4449 | + switch ($start_of_week = (int) get_option('start_of_week')) { |
|
| 4450 | 4450 | case 1 : |
| 4451 | 4451 | return "WEEK( $column, 1 )"; |
| 4452 | 4452 | case 2 : |
@@ -4474,13 +4474,13 @@ discard block |
||
| 4474 | 4474 | * @param array $callback_args Optional. Additional arguments to send to $callback. |
| 4475 | 4475 | * @return array IDs of all members of loop. |
| 4476 | 4476 | */ |
| 4477 | -function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { |
|
| 4478 | - $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); |
|
| 4477 | +function wp_find_hierarchy_loop($callback, $start, $start_parent, $callback_args = array()) { |
|
| 4478 | + $override = is_null($start_parent) ? array() : array($start => $start_parent); |
|
| 4479 | 4479 | |
| 4480 | - if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) |
|
| 4480 | + if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override, $callback_args)) |
|
| 4481 | 4481 | return array(); |
| 4482 | 4482 | |
| 4483 | - return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); |
|
| 4483 | + return wp_find_hierarchy_loop_tortoise_hare($callback, $arbitrary_loop_member, $override, $callback_args, true); |
|
| 4484 | 4484 | } |
| 4485 | 4485 | |
| 4486 | 4486 | /** |
@@ -4503,7 +4503,7 @@ discard block |
||
| 4503 | 4503 | * @return mixed Scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if |
| 4504 | 4504 | * $_return_loop |
| 4505 | 4505 | */ |
| 4506 | -function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { |
|
| 4506 | +function wp_find_hierarchy_loop_tortoise_hare($callback, $start, $override = array(), $callback_args = array(), $_return_loop = false) { |
|
| 4507 | 4507 | $tortoise = $hare = $evanescent_hare = $start; |
| 4508 | 4508 | $return = array(); |
| 4509 | 4509 | |
@@ -4512,19 +4512,19 @@ discard block |
||
| 4512 | 4512 | while ( |
| 4513 | 4513 | $tortoise |
| 4514 | 4514 | && |
| 4515 | - ( $evanescent_hare = isset( $override[$hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) |
|
| 4515 | + ($evanescent_hare = isset($override[$hare]) ? $override[$hare] : call_user_func_array($callback, array_merge(array($hare), $callback_args))) |
|
| 4516 | 4516 | && |
| 4517 | - ( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) |
|
| 4517 | + ($hare = isset($override[$evanescent_hare]) ? $override[$evanescent_hare] : call_user_func_array($callback, array_merge(array($evanescent_hare), $callback_args))) |
|
| 4518 | 4518 | ) { |
| 4519 | - if ( $_return_loop ) |
|
| 4519 | + if ($_return_loop) |
|
| 4520 | 4520 | $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; |
| 4521 | 4521 | |
| 4522 | 4522 | // tortoise got lapped - must be a loop |
| 4523 | - if ( $tortoise == $evanescent_hare || $tortoise == $hare ) |
|
| 4523 | + if ($tortoise == $evanescent_hare || $tortoise == $hare) |
|
| 4524 | 4524 | return $_return_loop ? $return : $tortoise; |
| 4525 | 4525 | |
| 4526 | 4526 | // Increment tortoise by one step |
| 4527 | - $tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); |
|
| 4527 | + $tortoise = isset($override[$tortoise]) ? $override[$tortoise] : call_user_func_array($callback, array_merge(array($tortoise), $callback_args)); |
|
| 4528 | 4528 | } |
| 4529 | 4529 | |
| 4530 | 4530 | return false; |
@@ -4538,7 +4538,7 @@ discard block |
||
| 4538 | 4538 | * @see https://developer.mozilla.org/en/the_x-frame-options_response_header |
| 4539 | 4539 | */ |
| 4540 | 4540 | function send_frame_options_header() { |
| 4541 | - @header( 'X-Frame-Options: SAMEORIGIN' ); |
|
| 4541 | + @header('X-Frame-Options: SAMEORIGIN'); |
|
| 4542 | 4542 | } |
| 4543 | 4543 | |
| 4544 | 4544 | /** |
@@ -4559,8 +4559,8 @@ discard block |
||
| 4559 | 4559 | function wp_allowed_protocols() { |
| 4560 | 4560 | static $protocols = array(); |
| 4561 | 4561 | |
| 4562 | - if ( empty( $protocols ) ) { |
|
| 4563 | - $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal' ); |
|
| 4562 | + if (empty($protocols)) { |
|
| 4563 | + $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp', 'webcal'); |
|
| 4564 | 4564 | |
| 4565 | 4565 | /** |
| 4566 | 4566 | * Filter the list of protocols allowed in HTML attributes. |
@@ -4569,7 +4569,7 @@ discard block |
||
| 4569 | 4569 | * |
| 4570 | 4570 | * @param array $protocols Array of allowed protocols e.g. 'http', 'ftp', 'tel', and more. |
| 4571 | 4571 | */ |
| 4572 | - $protocols = apply_filters( 'kses_allowed_protocols', $protocols ); |
|
| 4572 | + $protocols = apply_filters('kses_allowed_protocols', $protocols); |
|
| 4573 | 4573 | } |
| 4574 | 4574 | |
| 4575 | 4575 | return $protocols; |
@@ -4592,36 +4592,36 @@ discard block |
||
| 4592 | 4592 | * @return string|array Either a string containing a reversed comma separated trace or an array |
| 4593 | 4593 | * of individual calls. |
| 4594 | 4594 | */ |
| 4595 | -function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { |
|
| 4596 | - if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) |
|
| 4597 | - $trace = debug_backtrace( false ); |
|
| 4595 | +function wp_debug_backtrace_summary($ignore_class = null, $skip_frames = 0, $pretty = true) { |
|
| 4596 | + if (version_compare(PHP_VERSION, '5.2.5', '>=')) |
|
| 4597 | + $trace = debug_backtrace(false); |
|
| 4598 | 4598 | else |
| 4599 | 4599 | $trace = debug_backtrace(); |
| 4600 | 4600 | |
| 4601 | 4601 | $caller = array(); |
| 4602 | - $check_class = ! is_null( $ignore_class ); |
|
| 4602 | + $check_class = ! is_null($ignore_class); |
|
| 4603 | 4603 | $skip_frames++; // skip this function |
| 4604 | 4604 | |
| 4605 | - foreach ( $trace as $call ) { |
|
| 4606 | - if ( $skip_frames > 0 ) { |
|
| 4605 | + foreach ($trace as $call) { |
|
| 4606 | + if ($skip_frames > 0) { |
|
| 4607 | 4607 | $skip_frames--; |
| 4608 | - } elseif ( isset( $call['class'] ) ) { |
|
| 4609 | - if ( $check_class && $ignore_class == $call['class'] ) |
|
| 4608 | + } elseif (isset($call['class'])) { |
|
| 4609 | + if ($check_class && $ignore_class == $call['class']) |
|
| 4610 | 4610 | continue; // Filter out calls |
| 4611 | 4611 | |
| 4612 | 4612 | $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; |
| 4613 | 4613 | } else { |
| 4614 | - if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) { |
|
| 4614 | + if (in_array($call['function'], array('do_action', 'apply_filters'))) { |
|
| 4615 | 4615 | $caller[] = "{$call['function']}('{$call['args'][0]}')"; |
| 4616 | - } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { |
|
| 4617 | - $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')"; |
|
| 4616 | + } elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) { |
|
| 4617 | + $caller[] = $call['function']."('".str_replace(array(WP_CONTENT_DIR, ABSPATH), '', $call['args'][0])."')"; |
|
| 4618 | 4618 | } else { |
| 4619 | 4619 | $caller[] = $call['function']; |
| 4620 | 4620 | } |
| 4621 | 4621 | } |
| 4622 | 4622 | } |
| 4623 | - if ( $pretty ) |
|
| 4624 | - return join( ', ', array_reverse( $caller ) ); |
|
| 4623 | + if ($pretty) |
|
| 4624 | + return join(', ', array_reverse($caller)); |
|
| 4625 | 4625 | else |
| 4626 | 4626 | return $caller; |
| 4627 | 4627 | } |
@@ -4637,11 +4637,11 @@ discard block |
||
| 4637 | 4637 | * |
| 4638 | 4638 | * @return array List of ids not present in the cache. |
| 4639 | 4639 | */ |
| 4640 | -function _get_non_cached_ids( $object_ids, $cache_key ) { |
|
| 4640 | +function _get_non_cached_ids($object_ids, $cache_key) { |
|
| 4641 | 4641 | $clean = array(); |
| 4642 | - foreach ( $object_ids as $id ) { |
|
| 4642 | + foreach ($object_ids as $id) { |
|
| 4643 | 4643 | $id = (int) $id; |
| 4644 | - if ( !wp_cache_get( $id, $cache_key ) ) { |
|
| 4644 | + if ( ! wp_cache_get($id, $cache_key)) { |
|
| 4645 | 4645 | $clean[] = $id; |
| 4646 | 4646 | } |
| 4647 | 4647 | } |
@@ -4658,15 +4658,15 @@ discard block |
||
| 4658 | 4658 | * @return bool Whether the device is able to upload files. |
| 4659 | 4659 | */ |
| 4660 | 4660 | function _device_can_upload() { |
| 4661 | - if ( ! wp_is_mobile() ) |
|
| 4661 | + if ( ! wp_is_mobile()) |
|
| 4662 | 4662 | return true; |
| 4663 | 4663 | |
| 4664 | 4664 | $ua = $_SERVER['HTTP_USER_AGENT']; |
| 4665 | 4665 | |
| 4666 | - if ( strpos($ua, 'iPhone') !== false |
|
| 4666 | + if (strpos($ua, 'iPhone') !== false |
|
| 4667 | 4667 | || strpos($ua, 'iPad') !== false |
| 4668 | - || strpos($ua, 'iPod') !== false ) { |
|
| 4669 | - return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' ); |
|
| 4668 | + || strpos($ua, 'iPod') !== false) { |
|
| 4669 | + return preg_match('#OS ([\d_]+) like Mac OS X#', $ua, $version) && version_compare($version[1], '6', '>='); |
|
| 4670 | 4670 | } |
| 4671 | 4671 | |
| 4672 | 4672 | return true; |
@@ -4678,11 +4678,11 @@ discard block |
||
| 4678 | 4678 | * @param string $path The resource path or URL. |
| 4679 | 4679 | * @return bool True if the path is a stream URL. |
| 4680 | 4680 | */ |
| 4681 | -function wp_is_stream( $path ) { |
|
| 4681 | +function wp_is_stream($path) { |
|
| 4682 | 4682 | $wrappers = stream_get_wrappers(); |
| 4683 | - $wrappers_re = '(' . join('|', $wrappers) . ')'; |
|
| 4683 | + $wrappers_re = '('.join('|', $wrappers).')'; |
|
| 4684 | 4684 | |
| 4685 | - return preg_match( "!^$wrappers_re://!", $path ) === 1; |
|
| 4685 | + return preg_match("!^$wrappers_re://!", $path) === 1; |
|
| 4686 | 4686 | } |
| 4687 | 4687 | |
| 4688 | 4688 | /** |
@@ -4698,7 +4698,7 @@ discard block |
||
| 4698 | 4698 | * @param string $source_date The date to filter. |
| 4699 | 4699 | * @return bool True if valid date, false if not valid date. |
| 4700 | 4700 | */ |
| 4701 | -function wp_checkdate( $month, $day, $year, $source_date ) { |
|
| 4701 | +function wp_checkdate($month, $day, $year, $source_date) { |
|
| 4702 | 4702 | /** |
| 4703 | 4703 | * Filter whether the given date is valid for the Gregorian calendar. |
| 4704 | 4704 | * |
@@ -4707,7 +4707,7 @@ discard block |
||
| 4707 | 4707 | * @param bool $checkdate Whether the given date is valid. |
| 4708 | 4708 | * @param string $source_date Date to check. |
| 4709 | 4709 | */ |
| 4710 | - return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date ); |
|
| 4710 | + return apply_filters('wp_checkdate', checkdate($month, $day, $year), $source_date); |
|
| 4711 | 4711 | } |
| 4712 | 4712 | |
| 4713 | 4713 | /** |
@@ -4722,15 +4722,15 @@ discard block |
||
| 4722 | 4722 | * @since 3.6.0 |
| 4723 | 4723 | */ |
| 4724 | 4724 | function wp_auth_check_load() { |
| 4725 | - if ( ! is_admin() && ! is_user_logged_in() ) |
|
| 4725 | + if ( ! is_admin() && ! is_user_logged_in()) |
|
| 4726 | 4726 | return; |
| 4727 | 4727 | |
| 4728 | - if ( defined( 'IFRAME_REQUEST' ) ) |
|
| 4728 | + if (defined('IFRAME_REQUEST')) |
|
| 4729 | 4729 | return; |
| 4730 | 4730 | |
| 4731 | 4731 | $screen = get_current_screen(); |
| 4732 | - $hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' ); |
|
| 4733 | - $show = ! in_array( $screen->id, $hidden ); |
|
| 4732 | + $hidden = array('update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network'); |
|
| 4733 | + $show = ! in_array($screen->id, $hidden); |
|
| 4734 | 4734 | |
| 4735 | 4735 | /** |
| 4736 | 4736 | * Filter whether to load the authentication check. |
@@ -4743,12 +4743,12 @@ discard block |
||
| 4743 | 4743 | * @param bool $show Whether to load the authentication check. |
| 4744 | 4744 | * @param WP_Screen $screen The current screen object. |
| 4745 | 4745 | */ |
| 4746 | - if ( apply_filters( 'wp_auth_check_load', $show, $screen ) ) { |
|
| 4747 | - wp_enqueue_style( 'wp-auth-check' ); |
|
| 4748 | - wp_enqueue_script( 'wp-auth-check' ); |
|
| 4746 | + if (apply_filters('wp_auth_check_load', $show, $screen)) { |
|
| 4747 | + wp_enqueue_style('wp-auth-check'); |
|
| 4748 | + wp_enqueue_script('wp-auth-check'); |
|
| 4749 | 4749 | |
| 4750 | - add_action( 'admin_print_footer_scripts', 'wp_auth_check_html', 5 ); |
|
| 4751 | - add_action( 'wp_print_footer_scripts', 'wp_auth_check_html', 5 ); |
|
| 4750 | + add_action('admin_print_footer_scripts', 'wp_auth_check_html', 5); |
|
| 4751 | + add_action('wp_print_footer_scripts', 'wp_auth_check_html', 5); |
|
| 4752 | 4752 | } |
| 4753 | 4753 | } |
| 4754 | 4754 | |
@@ -4759,8 +4759,8 @@ discard block |
||
| 4759 | 4759 | */ |
| 4760 | 4760 | function wp_auth_check_html() { |
| 4761 | 4761 | $login_url = wp_login_url(); |
| 4762 | - $current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']; |
|
| 4763 | - $same_domain = ( strpos( $login_url, $current_domain ) === 0 ); |
|
| 4762 | + $current_domain = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST']; |
|
| 4763 | + $same_domain = (strpos($login_url, $current_domain) === 0); |
|
| 4764 | 4764 | |
| 4765 | 4765 | /** |
| 4766 | 4766 | * Filter whether the authentication check originated at the same domain. |
@@ -4769,7 +4769,7 @@ discard block |
||
| 4769 | 4769 | * |
| 4770 | 4770 | * @param bool $same_domain Whether the authentication check originated at the same domain. |
| 4771 | 4771 | */ |
| 4772 | - $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); |
|
| 4772 | + $same_domain = apply_filters('wp_auth_check_same_domain', $same_domain); |
|
| 4773 | 4773 | $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; |
| 4774 | 4774 | |
| 4775 | 4775 | ?> |
@@ -4779,16 +4779,16 @@ discard block |
||
| 4779 | 4779 | <div class="wp-auth-check-close" tabindex="0" title="<?php esc_attr_e('Close'); ?>"></div> |
| 4780 | 4780 | <?php |
| 4781 | 4781 | |
| 4782 | - if ( $same_domain ) { |
|
| 4782 | + if ($same_domain) { |
|
| 4783 | 4783 | ?> |
| 4784 | - <div id="wp-auth-check-form" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div> |
|
| 4784 | + <div id="wp-auth-check-form" data-src="<?php echo esc_url(add_query_arg(array('interim-login' => 1), $login_url)); ?>"></div> |
|
| 4785 | 4785 | <?php |
| 4786 | 4786 | } |
| 4787 | 4787 | |
| 4788 | 4788 | ?> |
| 4789 | 4789 | <div class="wp-auth-fallback"> |
| 4790 | 4790 | <p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e('Session expired'); ?></b></p> |
| 4791 | - <p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e('Please log in again.'); ?></a> |
|
| 4791 | + <p><a href="<?php echo esc_url($login_url); ?>" target="_blank"><?php _e('Please log in again.'); ?></a> |
|
| 4792 | 4792 | <?php _e('The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p> |
| 4793 | 4793 | </div> |
| 4794 | 4794 | </div> |
@@ -4809,8 +4809,8 @@ discard block |
||
| 4809 | 4809 | * @param array $response The Heartbeat response. |
| 4810 | 4810 | * @return array $response The Heartbeat response with 'wp-auth-check' value set. |
| 4811 | 4811 | */ |
| 4812 | -function wp_auth_check( $response ) { |
|
| 4813 | - $response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] ); |
|
| 4812 | +function wp_auth_check($response) { |
|
| 4813 | + $response['wp-auth-check'] = is_user_logged_in() && empty($GLOBALS['login_grace_period']); |
|
| 4814 | 4814 | return $response; |
| 4815 | 4815 | } |
| 4816 | 4816 | |
@@ -4830,10 +4830,10 @@ discard block |
||
| 4830 | 4830 | * @param string $tag An HTML tag name. Example: 'video'. |
| 4831 | 4831 | * @return string Tag RegEx. |
| 4832 | 4832 | */ |
| 4833 | -function get_tag_regex( $tag ) { |
|
| 4834 | - if ( empty( $tag ) ) |
|
| 4833 | +function get_tag_regex($tag) { |
|
| 4834 | + if (empty($tag)) |
|
| 4835 | 4835 | return; |
| 4836 | - return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) ); |
|
| 4836 | + return sprintf('<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape($tag)); |
|
| 4837 | 4837 | } |
| 4838 | 4838 | |
| 4839 | 4839 | /** |
@@ -4848,13 +4848,13 @@ discard block |
||
| 4848 | 4848 | * @param string $charset A charset name. |
| 4849 | 4849 | * @return string The canonical form of the charset. |
| 4850 | 4850 | */ |
| 4851 | -function _canonical_charset( $charset ) { |
|
| 4852 | - if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || |
|
| 4853 | - 'UTF8' === $charset ) |
|
| 4851 | +function _canonical_charset($charset) { |
|
| 4852 | + if ('UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || |
|
| 4853 | + 'UTF8' === $charset) |
|
| 4854 | 4854 | return 'UTF-8'; |
| 4855 | 4855 | |
| 4856 | - if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset || |
|
| 4857 | - 'iso8859-1' === $charset || 'ISO8859-1' === $charset ) |
|
| 4856 | + if ('ISO-8859-1' === $charset || 'iso-8859-1' === $charset || |
|
| 4857 | + 'iso8859-1' === $charset || 'ISO8859-1' === $charset) |
|
| 4858 | 4858 | return 'ISO-8859-1'; |
| 4859 | 4859 | |
| 4860 | 4860 | return $charset; |
@@ -4886,25 +4886,25 @@ discard block |
||
| 4886 | 4886 | * @param bool $reset Optional. Whether to reset the encoding back to a previously-set encoding. |
| 4887 | 4887 | * Default false. |
| 4888 | 4888 | */ |
| 4889 | -function mbstring_binary_safe_encoding( $reset = false ) { |
|
| 4889 | +function mbstring_binary_safe_encoding($reset = false) { |
|
| 4890 | 4890 | static $encodings = array(); |
| 4891 | 4891 | static $overloaded = null; |
| 4892 | 4892 | |
| 4893 | - if ( is_null( $overloaded ) ) |
|
| 4894 | - $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); |
|
| 4893 | + if (is_null($overloaded)) |
|
| 4894 | + $overloaded = function_exists('mb_internal_encoding') && (ini_get('mbstring.func_overload') & 2); |
|
| 4895 | 4895 | |
| 4896 | - if ( false === $overloaded ) |
|
| 4896 | + if (false === $overloaded) |
|
| 4897 | 4897 | return; |
| 4898 | 4898 | |
| 4899 | - if ( ! $reset ) { |
|
| 4899 | + if ( ! $reset) { |
|
| 4900 | 4900 | $encoding = mb_internal_encoding(); |
| 4901 | - array_push( $encodings, $encoding ); |
|
| 4902 | - mb_internal_encoding( 'ISO-8859-1' ); |
|
| 4901 | + array_push($encodings, $encoding); |
|
| 4902 | + mb_internal_encoding('ISO-8859-1'); |
|
| 4903 | 4903 | } |
| 4904 | 4904 | |
| 4905 | - if ( $reset && $encodings ) { |
|
| 4906 | - $encoding = array_pop( $encodings ); |
|
| 4907 | - mb_internal_encoding( $encoding ); |
|
| 4905 | + if ($reset && $encodings) { |
|
| 4906 | + $encoding = array_pop($encodings); |
|
| 4907 | + mb_internal_encoding($encoding); |
|
| 4908 | 4908 | } |
| 4909 | 4909 | } |
| 4910 | 4910 | |
@@ -4916,7 +4916,7 @@ discard block |
||
| 4916 | 4916 | * @since 3.7.0 |
| 4917 | 4917 | */ |
| 4918 | 4918 | function reset_mbstring_encoding() { |
| 4919 | - mbstring_binary_safe_encoding( true ); |
|
| 4919 | + mbstring_binary_safe_encoding(true); |
|
| 4920 | 4920 | } |
| 4921 | 4921 | |
| 4922 | 4922 | /** |
@@ -4929,12 +4929,12 @@ discard block |
||
| 4929 | 4929 | * @param mixed $var Boolean value to validate. |
| 4930 | 4930 | * @return bool Whether the value is validated. |
| 4931 | 4931 | */ |
| 4932 | -function wp_validate_boolean( $var ) { |
|
| 4933 | - if ( is_bool( $var ) ) { |
|
| 4932 | +function wp_validate_boolean($var) { |
|
| 4933 | + if (is_bool($var)) { |
|
| 4934 | 4934 | return $var; |
| 4935 | 4935 | } |
| 4936 | 4936 | |
| 4937 | - if ( is_string( $var ) && 'false' === strtolower( $var ) ) { |
|
| 4937 | + if (is_string($var) && 'false' === strtolower($var)) { |
|
| 4938 | 4938 | return false; |
| 4939 | 4939 | } |
| 4940 | 4940 | |
@@ -4948,7 +4948,7 @@ discard block |
||
| 4948 | 4948 | * |
| 4949 | 4949 | * @param string $file The path to the file to delete. |
| 4950 | 4950 | */ |
| 4951 | -function wp_delete_file( $file ) { |
|
| 4951 | +function wp_delete_file($file) { |
|
| 4952 | 4952 | /** |
| 4953 | 4953 | * Filter the path of the file to delete. |
| 4954 | 4954 | * |
@@ -4956,9 +4956,9 @@ discard block |
||
| 4956 | 4956 | * |
| 4957 | 4957 | * @param string $medium Path to the file to delete. |
| 4958 | 4958 | */ |
| 4959 | - $delete = apply_filters( 'wp_delete_file', $file ); |
|
| 4960 | - if ( ! empty( $delete ) ) { |
|
| 4961 | - @unlink( $delete ); |
|
| 4959 | + $delete = apply_filters('wp_delete_file', $file); |
|
| 4960 | + if ( ! empty($delete)) { |
|
| 4961 | + @unlink($delete); |
|
| 4962 | 4962 | } |
| 4963 | 4963 | } |
| 4964 | 4964 | |
@@ -4972,12 +4972,12 @@ discard block |
||
| 4972 | 4972 | function wp_post_preview_js() { |
| 4973 | 4973 | global $post; |
| 4974 | 4974 | |
| 4975 | - if ( ! is_preview() || empty( $post ) ) { |
|
| 4975 | + if ( ! is_preview() || empty($post)) { |
|
| 4976 | 4976 | return; |
| 4977 | 4977 | } |
| 4978 | 4978 | |
| 4979 | 4979 | // Has to match the window name used in post_submit_meta_box() |
| 4980 | - $name = 'wp-preview-' . (int) $post->ID; |
|
| 4980 | + $name = 'wp-preview-'.(int) $post->ID; |
|
| 4981 | 4981 | |
| 4982 | 4982 | ?> |
| 4983 | 4983 | <script> |
@@ -24,22 +24,26 @@ discard block |
||
| 24 | 24 | * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty. |
| 25 | 25 | */ |
| 26 | 26 | function mysql2date( $format, $date, $translate = true ) { |
| 27 | - if ( empty( $date ) ) |
|
| 28 | - return false; |
|
| 27 | + if ( empty( $date ) ) { |
|
| 28 | + return false; |
|
| 29 | + } |
|
| 29 | 30 | |
| 30 | - if ( 'G' == $format ) |
|
| 31 | - return strtotime( $date . ' +0000' ); |
|
| 31 | + if ( 'G' == $format ) { |
|
| 32 | + return strtotime( $date . ' +0000' ); |
|
| 33 | + } |
|
| 32 | 34 | |
| 33 | 35 | $i = strtotime( $date ); |
| 34 | 36 | |
| 35 | - if ( 'U' == $format ) |
|
| 36 | - return $i; |
|
| 37 | + if ( 'U' == $format ) { |
|
| 38 | + return $i; |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | - if ( $translate ) |
|
| 39 | - return date_i18n( $format, $i ); |
|
| 40 | - else |
|
| 41 | - return date( $format, $i ); |
|
| 42 | -} |
|
| 41 | + if ( $translate ) { |
|
| 42 | + return date_i18n( $format, $i ); |
|
| 43 | + } else { |
|
| 44 | + return date( $format, $i ); |
|
| 45 | + } |
|
| 46 | + } |
|
| 43 | 47 | |
| 44 | 48 | /** |
| 45 | 49 | * Retrieve the current time based on specified type. |
@@ -91,10 +95,11 @@ discard block |
||
| 91 | 95 | $i = $unixtimestamp; |
| 92 | 96 | |
| 93 | 97 | if ( false === $i ) { |
| 94 | - if ( ! $gmt ) |
|
| 95 | - $i = current_time( 'timestamp' ); |
|
| 96 | - else |
|
| 97 | - $i = time(); |
|
| 98 | + if ( ! $gmt ) { |
|
| 99 | + $i = current_time( 'timestamp' ); |
|
| 100 | + } else { |
|
| 101 | + $i = time(); |
|
| 102 | + } |
|
| 98 | 103 | // we should not let date() interfere with our |
| 99 | 104 | // specially computed timestamp |
| 100 | 105 | $gmt = true; |
@@ -247,11 +252,13 @@ discard block |
||
| 247 | 252 | // The day of the week from the timestamp. |
| 248 | 253 | $weekday = date( 'w', $day ); |
| 249 | 254 | |
| 250 | - if ( !is_numeric($start_of_week) ) |
|
| 251 | - $start_of_week = get_option( 'start_of_week' ); |
|
| 255 | + if ( !is_numeric($start_of_week) ) { |
|
| 256 | + $start_of_week = get_option( 'start_of_week' ); |
|
| 257 | + } |
|
| 252 | 258 | |
| 253 | - if ( $weekday < $start_of_week ) |
|
| 254 | - $weekday += 7; |
|
| 259 | + if ( $weekday < $start_of_week ) { |
|
| 260 | + $weekday += 7; |
|
| 261 | + } |
|
| 255 | 262 | |
| 256 | 263 | // The most recent week start day on or before $day. |
| 257 | 264 | $start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); |
@@ -270,8 +277,10 @@ discard block |
||
| 270 | 277 | * @return mixed Unserialized data can be any type. |
| 271 | 278 | */ |
| 272 | 279 | function maybe_unserialize( $original ) { |
| 273 | - if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in |
|
| 280 | + if ( is_serialized( $original ) ) { |
|
| 281 | + // don't attempt to unserialize data that wasn't serialized going in |
|
| 274 | 282 | return @unserialize( $original ); |
| 283 | + } |
|
| 275 | 284 | return $original; |
| 276 | 285 | } |
| 277 | 286 | |
@@ -311,13 +320,16 @@ discard block |
||
| 311 | 320 | $semicolon = strpos( $data, ';' ); |
| 312 | 321 | $brace = strpos( $data, '}' ); |
| 313 | 322 | // Either ; or } must exist. |
| 314 | - if ( false === $semicolon && false === $brace ) |
|
| 315 | - return false; |
|
| 323 | + if ( false === $semicolon && false === $brace ) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 316 | 326 | // But neither must be in the first X characters. |
| 317 | - if ( false !== $semicolon && $semicolon < 3 ) |
|
| 318 | - return false; |
|
| 319 | - if ( false !== $brace && $brace < 4 ) |
|
| 320 | - return false; |
|
| 327 | + if ( false !== $semicolon && $semicolon < 3 ) { |
|
| 328 | + return false; |
|
| 329 | + } |
|
| 330 | + if ( false !== $brace && $brace < 4 ) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 321 | 333 | } |
| 322 | 334 | $token = $data[0]; |
| 323 | 335 | switch ( $token ) { |
@@ -380,14 +392,16 @@ discard block |
||
| 380 | 392 | * @return mixed A scalar data |
| 381 | 393 | */ |
| 382 | 394 | function maybe_serialize( $data ) { |
| 383 | - if ( is_array( $data ) || is_object( $data ) ) |
|
| 384 | - return serialize( $data ); |
|
| 395 | + if ( is_array( $data ) || is_object( $data ) ) { |
|
| 396 | + return serialize( $data ); |
|
| 397 | + } |
|
| 385 | 398 | |
| 386 | 399 | // Double serialization is required for backward compatibility. |
| 387 | 400 | // See https://core.trac.wordpress.org/ticket/12930 |
| 388 | 401 | // Also the world will end. See WP 3.6.1. |
| 389 | - if ( is_serialized( $data, false ) ) |
|
| 390 | - return serialize( $data ); |
|
| 402 | + if ( is_serialized( $data, false ) ) { |
|
| 403 | + return serialize( $data ); |
|
| 404 | + } |
|
| 391 | 405 | |
| 392 | 406 | return $data; |
| 393 | 407 | } |
@@ -515,20 +529,23 @@ discard block |
||
| 515 | 529 | foreach ( $pung as $link_test ) { |
| 516 | 530 | if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post |
| 517 | 531 | $mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%') ); |
| 518 | - foreach ( $mids as $mid ) |
|
| 519 | - delete_metadata_by_mid( 'post', $mid ); |
|
| 532 | + foreach ( $mids as $mid ) { |
|
| 533 | + delete_metadata_by_mid( 'post', $mid ); |
|
| 534 | + } |
|
| 520 | 535 | } |
| 521 | 536 | } |
| 522 | 537 | |
| 523 | 538 | foreach ( (array) $post_links_temp as $link_test ) { |
| 524 | 539 | if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already |
| 525 | 540 | $test = @parse_url( $link_test ); |
| 526 | - if ( false === $test ) |
|
| 527 | - continue; |
|
| 528 | - if ( isset( $test['query'] ) ) |
|
| 529 | - $post_links[] = $link_test; |
|
| 530 | - elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) ) |
|
| 531 | - $post_links[] = $link_test; |
|
| 541 | + if ( false === $test ) { |
|
| 542 | + continue; |
|
| 543 | + } |
|
| 544 | + if ( isset( $test['query'] ) ) { |
|
| 545 | + $post_links[] = $link_test; |
|
| 546 | + } elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) ) { |
|
| 547 | + $post_links[] = $link_test; |
|
| 548 | + } |
|
| 532 | 549 | } |
| 533 | 550 | } |
| 534 | 551 | |
@@ -580,21 +597,24 @@ discard block |
||
| 580 | 597 | function wp_get_http( $url, $file_path = false, $red = 1 ) { |
| 581 | 598 | @set_time_limit( 60 ); |
| 582 | 599 | |
| 583 | - if ( $red > 5 ) |
|
| 584 | - return false; |
|
| 600 | + if ( $red > 5 ) { |
|
| 601 | + return false; |
|
| 602 | + } |
|
| 585 | 603 | |
| 586 | 604 | $options = array(); |
| 587 | 605 | $options['redirection'] = 5; |
| 588 | 606 | |
| 589 | - if ( false == $file_path ) |
|
| 590 | - $options['method'] = 'HEAD'; |
|
| 591 | - else |
|
| 592 | - $options['method'] = 'GET'; |
|
| 607 | + if ( false == $file_path ) { |
|
| 608 | + $options['method'] = 'HEAD'; |
|
| 609 | + } else { |
|
| 610 | + $options['method'] = 'GET'; |
|
| 611 | + } |
|
| 593 | 612 | |
| 594 | 613 | $response = wp_safe_remote_request( $url, $options ); |
| 595 | 614 | |
| 596 | - if ( is_wp_error( $response ) ) |
|
| 597 | - return false; |
|
| 615 | + if ( is_wp_error( $response ) ) { |
|
| 616 | + return false; |
|
| 617 | + } |
|
| 598 | 618 | |
| 599 | 619 | $headers = wp_remote_retrieve_headers( $response ); |
| 600 | 620 | $headers['response'] = wp_remote_retrieve_response_code( $response ); |
@@ -604,13 +624,15 @@ discard block |
||
| 604 | 624 | return wp_get_http( $headers['location'], $file_path, ++$red ); |
| 605 | 625 | } |
| 606 | 626 | |
| 607 | - if ( false == $file_path ) |
|
| 608 | - return $headers; |
|
| 627 | + if ( false == $file_path ) { |
|
| 628 | + return $headers; |
|
| 629 | + } |
|
| 609 | 630 | |
| 610 | 631 | // GET request - write it to the supplied filename |
| 611 | 632 | $out_fp = fopen($file_path, 'w'); |
| 612 | - if ( !$out_fp ) |
|
| 613 | - return $headers; |
|
| 633 | + if ( !$out_fp ) { |
|
| 634 | + return $headers; |
|
| 635 | + } |
|
| 614 | 636 | |
| 615 | 637 | fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); |
| 616 | 638 | fclose($out_fp); |
@@ -629,13 +651,15 @@ discard block |
||
| 629 | 651 | * @return bool|string False on failure, headers on success. |
| 630 | 652 | */ |
| 631 | 653 | function wp_get_http_headers( $url, $deprecated = false ) { |
| 632 | - if ( !empty( $deprecated ) ) |
|
| 633 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 654 | + if ( !empty( $deprecated ) ) { |
|
| 655 | + _deprecated_argument( __FUNCTION__, '2.7' ); |
|
| 656 | + } |
|
| 634 | 657 | |
| 635 | 658 | $response = wp_safe_remote_head( $url ); |
| 636 | 659 | |
| 637 | - if ( is_wp_error( $response ) ) |
|
| 638 | - return false; |
|
| 660 | + if ( is_wp_error( $response ) ) { |
|
| 661 | + return false; |
|
| 662 | + } |
|
| 639 | 663 | |
| 640 | 664 | return wp_remote_retrieve_headers( $response ); |
| 641 | 665 | } |
@@ -653,11 +677,12 @@ discard block |
||
| 653 | 677 | */ |
| 654 | 678 | function is_new_day() { |
| 655 | 679 | global $currentday, $previousday; |
| 656 | - if ( $currentday != $previousday ) |
|
| 657 | - return 1; |
|
| 658 | - else |
|
| 659 | - return 0; |
|
| 660 | -} |
|
| 680 | + if ( $currentday != $previousday ) { |
|
| 681 | + return 1; |
|
| 682 | + } else { |
|
| 683 | + return 0; |
|
| 684 | + } |
|
| 685 | + } |
|
| 661 | 686 | |
| 662 | 687 | /** |
| 663 | 688 | * Build URL query based on an associative and, or indexed array. |
@@ -700,27 +725,33 @@ discard block |
||
| 700 | 725 | $ret = array(); |
| 701 | 726 | |
| 702 | 727 | foreach ( (array) $data as $k => $v ) { |
| 703 | - if ( $urlencode) |
|
| 704 | - $k = urlencode($k); |
|
| 705 | - if ( is_int($k) && $prefix != null ) |
|
| 706 | - $k = $prefix.$k; |
|
| 707 | - if ( !empty($key) ) |
|
| 708 | - $k = $key . '%5B' . $k . '%5D'; |
|
| 709 | - if ( $v === null ) |
|
| 710 | - continue; |
|
| 711 | - elseif ( $v === false ) |
|
| 712 | - $v = '0'; |
|
| 728 | + if ( $urlencode) { |
|
| 729 | + $k = urlencode($k); |
|
| 730 | + } |
|
| 731 | + if ( is_int($k) && $prefix != null ) { |
|
| 732 | + $k = $prefix.$k; |
|
| 733 | + } |
|
| 734 | + if ( !empty($key) ) { |
|
| 735 | + $k = $key . '%5B' . $k . '%5D'; |
|
| 736 | + } |
|
| 737 | + if ( $v === null ) { |
|
| 738 | + continue; |
|
| 739 | + } elseif ( $v === false ) { |
|
| 740 | + $v = '0'; |
|
| 741 | + } |
|
| 713 | 742 | |
| 714 | - if ( is_array($v) || is_object($v) ) |
|
| 715 | - array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); |
|
| 716 | - elseif ( $urlencode ) |
|
| 717 | - array_push($ret, $k.'='.urlencode($v)); |
|
| 718 | - else |
|
| 719 | - array_push($ret, $k.'='.$v); |
|
| 743 | + if ( is_array($v) || is_object($v) ) { |
|
| 744 | + array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); |
|
| 745 | + } elseif ( $urlencode ) { |
|
| 746 | + array_push($ret, $k.'='.urlencode($v)); |
|
| 747 | + } else { |
|
| 748 | + array_push($ret, $k.'='.$v); |
|
| 749 | + } |
|
| 720 | 750 | } |
| 721 | 751 | |
| 722 | - if ( null === $sep ) |
|
| 723 | - $sep = ini_get('arg_separator.output'); |
|
| 752 | + if ( null === $sep ) { |
|
| 753 | + $sep = ini_get('arg_separator.output'); |
|
| 754 | + } |
|
| 724 | 755 | |
| 725 | 756 | return implode($sep, $ret); |
| 726 | 757 | } |
@@ -746,21 +777,24 @@ discard block |
||
| 746 | 777 | function add_query_arg() { |
| 747 | 778 | $args = func_get_args(); |
| 748 | 779 | if ( is_array( $args[0] ) ) { |
| 749 | - if ( count( $args ) < 2 || false === $args[1] ) |
|
| 750 | - $uri = $_SERVER['REQUEST_URI']; |
|
| 751 | - else |
|
| 752 | - $uri = $args[1]; |
|
| 780 | + if ( count( $args ) < 2 || false === $args[1] ) { |
|
| 781 | + $uri = $_SERVER['REQUEST_URI']; |
|
| 782 | + } else { |
|
| 783 | + $uri = $args[1]; |
|
| 784 | + } |
|
| 753 | 785 | } else { |
| 754 | - if ( count( $args ) < 3 || false === $args[2] ) |
|
| 755 | - $uri = $_SERVER['REQUEST_URI']; |
|
| 756 | - else |
|
| 757 | - $uri = $args[2]; |
|
| 786 | + if ( count( $args ) < 3 || false === $args[2] ) { |
|
| 787 | + $uri = $_SERVER['REQUEST_URI']; |
|
| 788 | + } else { |
|
| 789 | + $uri = $args[2]; |
|
| 790 | + } |
|
| 758 | 791 | } |
| 759 | 792 | |
| 760 | - if ( $frag = strstr( $uri, '#' ) ) |
|
| 761 | - $uri = substr( $uri, 0, -strlen( $frag ) ); |
|
| 762 | - else |
|
| 763 | - $frag = ''; |
|
| 793 | + if ( $frag = strstr( $uri, '#' ) ) { |
|
| 794 | + $uri = substr( $uri, 0, -strlen( $frag ) ); |
|
| 795 | + } else { |
|
| 796 | + $frag = ''; |
|
| 797 | + } |
|
| 764 | 798 | |
| 765 | 799 | if ( 0 === stripos( $uri, 'http://' ) ) { |
| 766 | 800 | $protocol = 'http://'; |
@@ -794,8 +828,9 @@ discard block |
||
| 794 | 828 | } |
| 795 | 829 | |
| 796 | 830 | foreach ( $qs as $k => $v ) { |
| 797 | - if ( $v === false ) |
|
| 798 | - unset( $qs[$k] ); |
|
| 831 | + if ( $v === false ) { |
|
| 832 | + unset( $qs[$k] ); |
|
| 833 | + } |
|
| 799 | 834 | } |
| 800 | 835 | |
| 801 | 836 | $ret = build_query( $qs ); |
@@ -817,8 +852,9 @@ discard block |
||
| 817 | 852 | */ |
| 818 | 853 | function remove_query_arg( $key, $query = false ) { |
| 819 | 854 | if ( is_array( $key ) ) { // removing multiple keys |
| 820 | - foreach ( $key as $k ) |
|
| 821 | - $query = add_query_arg( $k, false, $query ); |
|
| 855 | + foreach ( $key as $k ) { |
|
| 856 | + $query = add_query_arg( $k, false, $query ); |
|
| 857 | + } |
|
| 822 | 858 | return $query; |
| 823 | 859 | } |
| 824 | 860 | return add_query_arg( $key, false, $query ); |
@@ -856,16 +892,18 @@ discard block |
||
| 856 | 892 | function wp_remote_fopen( $uri ) { |
| 857 | 893 | $parsed_url = @parse_url( $uri ); |
| 858 | 894 | |
| 859 | - if ( !$parsed_url || !is_array( $parsed_url ) ) |
|
| 860 | - return false; |
|
| 895 | + if ( !$parsed_url || !is_array( $parsed_url ) ) { |
|
| 896 | + return false; |
|
| 897 | + } |
|
| 861 | 898 | |
| 862 | 899 | $options = array(); |
| 863 | 900 | $options['timeout'] = 10; |
| 864 | 901 | |
| 865 | 902 | $response = wp_safe_remote_get( $uri, $options ); |
| 866 | 903 | |
| 867 | - if ( is_wp_error( $response ) ) |
|
| 868 | - return false; |
|
| 904 | + if ( is_wp_error( $response ) ) { |
|
| 905 | + return false; |
|
| 906 | + } |
|
| 869 | 907 | |
| 870 | 908 | return wp_remote_retrieve_body( $response ); |
| 871 | 909 | } |
@@ -885,9 +923,10 @@ discard block |
||
| 885 | 923 | global $wp, $wp_query, $wp_the_query; |
| 886 | 924 | $wp->main( $query_vars ); |
| 887 | 925 | |
| 888 | - if ( !isset($wp_the_query) ) |
|
| 889 | - $wp_the_query = $wp_query; |
|
| 890 | -} |
|
| 926 | + if ( !isset($wp_the_query) ) { |
|
| 927 | + $wp_the_query = $wp_query; |
|
| 928 | + } |
|
| 929 | + } |
|
| 891 | 930 | |
| 892 | 931 | /** |
| 893 | 932 | * Retrieve the description for the HTTP status. |
@@ -969,11 +1008,12 @@ discard block |
||
| 969 | 1008 | ); |
| 970 | 1009 | } |
| 971 | 1010 | |
| 972 | - if ( isset( $wp_header_to_desc[$code] ) ) |
|
| 973 | - return $wp_header_to_desc[$code]; |
|
| 974 | - else |
|
| 975 | - return ''; |
|
| 976 | -} |
|
| 1011 | + if ( isset( $wp_header_to_desc[$code] ) ) { |
|
| 1012 | + return $wp_header_to_desc[$code]; |
|
| 1013 | + } else { |
|
| 1014 | + return ''; |
|
| 1015 | + } |
|
| 1016 | + } |
|
| 977 | 1017 | |
| 978 | 1018 | /** |
| 979 | 1019 | * Set HTTP status header. |
@@ -987,15 +1027,17 @@ discard block |
||
| 987 | 1027 | function status_header( $code ) { |
| 988 | 1028 | $description = get_status_header_desc( $code ); |
| 989 | 1029 | |
| 990 | - if ( empty( $description ) ) |
|
| 991 | - return; |
|
| 1030 | + if ( empty( $description ) ) { |
|
| 1031 | + return; |
|
| 1032 | + } |
|
| 992 | 1033 | |
| 993 | 1034 | $protocol = $_SERVER['SERVER_PROTOCOL']; |
| 994 | - if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) |
|
| 995 | - $protocol = 'HTTP/1.0'; |
|
| 1035 | + if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) { |
|
| 1036 | + $protocol = 'HTTP/1.0'; |
|
| 1037 | + } |
|
| 996 | 1038 | $status_header = "$protocol $code $description"; |
| 997 | - if ( function_exists( 'apply_filters' ) ) |
|
| 998 | - |
|
| 1039 | + if ( function_exists( 'apply_filters' ) ) { |
|
| 1040 | + |
|
| 999 | 1041 | /** |
| 1000 | 1042 | * Filter an HTTP status header. |
| 1001 | 1043 | * |
@@ -1007,6 +1049,7 @@ discard block |
||
| 1007 | 1049 | * @param string $protocol Server protocol. |
| 1008 | 1050 | */ |
| 1009 | 1051 | $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); |
| 1052 | + } |
|
| 1010 | 1053 | |
| 1011 | 1054 | @header( $status_header, true, $code ); |
| 1012 | 1055 | } |
@@ -1080,9 +1123,10 @@ discard block |
||
| 1080 | 1123 | } |
| 1081 | 1124 | } |
| 1082 | 1125 | |
| 1083 | - foreach( $headers as $name => $field_value ) |
|
| 1084 | - @header("{$name}: {$field_value}"); |
|
| 1085 | -} |
|
| 1126 | + foreach( $headers as $name => $field_value ) { |
|
| 1127 | + @header("{$name}: {$field_value}"); |
|
| 1128 | + } |
|
| 1129 | + } |
|
| 1086 | 1130 | |
| 1087 | 1131 | /** |
| 1088 | 1132 | * Set the headers for caching for 10 days with JavaScript content type. |
@@ -1145,12 +1189,14 @@ discard block |
||
| 1145 | 1189 | // Remove the pad, if present. |
| 1146 | 1190 | $feed = preg_replace( '/^_+/', '', $feed ); |
| 1147 | 1191 | |
| 1148 | - if ( $feed == '' || $feed == 'feed' ) |
|
| 1149 | - $feed = get_default_feed(); |
|
| 1192 | + if ( $feed == '' || $feed == 'feed' ) { |
|
| 1193 | + $feed = get_default_feed(); |
|
| 1194 | + } |
|
| 1150 | 1195 | |
| 1151 | 1196 | $hook = 'do_feed_' . $feed; |
| 1152 | - if ( ! has_action( $hook ) ) |
|
| 1153 | - wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) ); |
|
| 1197 | + if ( ! has_action( $hook ) ) { |
|
| 1198 | + wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) ); |
|
| 1199 | + } |
|
| 1154 | 1200 | |
| 1155 | 1201 | /** |
| 1156 | 1202 | * Fires once the given feed is loaded. |
@@ -1196,11 +1242,12 @@ discard block |
||
| 1196 | 1242 | * @param bool $for_comments True for the comment feed, false for normal feed. |
| 1197 | 1243 | */ |
| 1198 | 1244 | function do_feed_rss2( $for_comments ) { |
| 1199 | - if ( $for_comments ) |
|
| 1200 | - load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); |
|
| 1201 | - else |
|
| 1202 | - load_template( ABSPATH . WPINC . '/feed-rss2.php' ); |
|
| 1203 | -} |
|
| 1245 | + if ( $for_comments ) { |
|
| 1246 | + load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); |
|
| 1247 | + } else { |
|
| 1248 | + load_template( ABSPATH . WPINC . '/feed-rss2.php' ); |
|
| 1249 | + } |
|
| 1250 | + } |
|
| 1204 | 1251 | |
| 1205 | 1252 | /** |
| 1206 | 1253 | * Load either Atom comment feed or Atom posts feed. |
@@ -1212,11 +1259,12 @@ discard block |
||
| 1212 | 1259 | * @param bool $for_comments True for the comment feed, false for normal feed. |
| 1213 | 1260 | */ |
| 1214 | 1261 | function do_feed_atom( $for_comments ) { |
| 1215 | - if ($for_comments) |
|
| 1216 | - load_template( ABSPATH . WPINC . '/feed-atom-comments.php'); |
|
| 1217 | - else |
|
| 1218 | - load_template( ABSPATH . WPINC . '/feed-atom.php' ); |
|
| 1219 | -} |
|
| 1262 | + if ($for_comments) { |
|
| 1263 | + load_template( ABSPATH . WPINC . '/feed-atom-comments.php'); |
|
| 1264 | + } else { |
|
| 1265 | + load_template( ABSPATH . WPINC . '/feed-atom.php' ); |
|
| 1266 | + } |
|
| 1267 | + } |
|
| 1220 | 1268 | |
| 1221 | 1269 | /** |
| 1222 | 1270 | * Display the robots.txt file content. |
@@ -1279,29 +1327,33 @@ discard block |
||
| 1279 | 1327 | * Check cache first. If options table goes away and we have true |
| 1280 | 1328 | * cached, oh well. |
| 1281 | 1329 | */ |
| 1282 | - if ( wp_cache_get( 'is_blog_installed' ) ) |
|
| 1283 | - return true; |
|
| 1330 | + if ( wp_cache_get( 'is_blog_installed' ) ) { |
|
| 1331 | + return true; |
|
| 1332 | + } |
|
| 1284 | 1333 | |
| 1285 | 1334 | $suppress = $wpdb->suppress_errors(); |
| 1286 | 1335 | if ( ! defined( 'WP_INSTALLING' ) ) { |
| 1287 | 1336 | $alloptions = wp_load_alloptions(); |
| 1288 | 1337 | } |
| 1289 | 1338 | // If siteurl is not set to autoload, check it specifically |
| 1290 | - if ( !isset( $alloptions['siteurl'] ) ) |
|
| 1291 | - $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); |
|
| 1292 | - else |
|
| 1293 | - $installed = $alloptions['siteurl']; |
|
| 1339 | + if ( !isset( $alloptions['siteurl'] ) ) { |
|
| 1340 | + $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); |
|
| 1341 | + } else { |
|
| 1342 | + $installed = $alloptions['siteurl']; |
|
| 1343 | + } |
|
| 1294 | 1344 | $wpdb->suppress_errors( $suppress ); |
| 1295 | 1345 | |
| 1296 | 1346 | $installed = !empty( $installed ); |
| 1297 | 1347 | wp_cache_set( 'is_blog_installed', $installed ); |
| 1298 | 1348 | |
| 1299 | - if ( $installed ) |
|
| 1300 | - return true; |
|
| 1349 | + if ( $installed ) { |
|
| 1350 | + return true; |
|
| 1351 | + } |
|
| 1301 | 1352 | |
| 1302 | 1353 | // If visiting repair.php, return true and let it take over. |
| 1303 | - if ( defined( 'WP_REPAIRING' ) ) |
|
| 1304 | - return true; |
|
| 1354 | + if ( defined( 'WP_REPAIRING' ) ) { |
|
| 1355 | + return true; |
|
| 1356 | + } |
|
| 1305 | 1357 | |
| 1306 | 1358 | $suppress = $wpdb->suppress_errors(); |
| 1307 | 1359 | |
@@ -1313,13 +1365,16 @@ discard block |
||
| 1313 | 1365 | $wp_tables = $wpdb->tables(); |
| 1314 | 1366 | foreach ( $wp_tables as $table ) { |
| 1315 | 1367 | // The existence of custom user tables shouldn't suggest an insane state or prevent a clean install. |
| 1316 | - if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) |
|
| 1317 | - continue; |
|
| 1318 | - if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) |
|
| 1319 | - continue; |
|
| 1368 | + if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) { |
|
| 1369 | + continue; |
|
| 1370 | + } |
|
| 1371 | + if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) { |
|
| 1372 | + continue; |
|
| 1373 | + } |
|
| 1320 | 1374 | |
| 1321 | - if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) |
|
| 1322 | - continue; |
|
| 1375 | + if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) { |
|
| 1376 | + continue; |
|
| 1377 | + } |
|
| 1323 | 1378 | |
| 1324 | 1379 | // One or more tables exist. We are insane. |
| 1325 | 1380 | |
@@ -1382,11 +1437,13 @@ discard block |
||
| 1382 | 1437 | $name = esc_attr( $name ); |
| 1383 | 1438 | $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; |
| 1384 | 1439 | |
| 1385 | - if ( $referer ) |
|
| 1386 | - $nonce_field .= wp_referer_field( false ); |
|
| 1440 | + if ( $referer ) { |
|
| 1441 | + $nonce_field .= wp_referer_field( false ); |
|
| 1442 | + } |
|
| 1387 | 1443 | |
| 1388 | - if ( $echo ) |
|
| 1389 | - echo $nonce_field; |
|
| 1444 | + if ( $echo ) { |
|
| 1445 | + echo $nonce_field; |
|
| 1446 | + } |
|
| 1390 | 1447 | |
| 1391 | 1448 | return $nonce_field; |
| 1392 | 1449 | } |
@@ -1405,8 +1462,9 @@ discard block |
||
| 1405 | 1462 | function wp_referer_field( $echo = true ) { |
| 1406 | 1463 | $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; |
| 1407 | 1464 | |
| 1408 | - if ( $echo ) |
|
| 1409 | - echo $referer_field; |
|
| 1465 | + if ( $echo ) { |
|
| 1466 | + echo $referer_field; |
|
| 1467 | + } |
|
| 1410 | 1468 | return $referer_field; |
| 1411 | 1469 | } |
| 1412 | 1470 | |
@@ -1429,8 +1487,9 @@ discard block |
||
| 1429 | 1487 | $ref = 'previous' == $jump_back_to ? wp_get_referer() : wp_unslash( $_SERVER['REQUEST_URI'] ); |
| 1430 | 1488 | } |
| 1431 | 1489 | $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; |
| 1432 | - if ( $echo ) |
|
| 1433 | - echo $orig_referer_field; |
|
| 1490 | + if ( $echo ) { |
|
| 1491 | + echo $orig_referer_field; |
|
| 1492 | + } |
|
| 1434 | 1493 | return $orig_referer_field; |
| 1435 | 1494 | } |
| 1436 | 1495 | |
@@ -1444,16 +1503,19 @@ discard block |
||
| 1444 | 1503 | * @return false|string False on failure. Referer URL on success. |
| 1445 | 1504 | */ |
| 1446 | 1505 | function wp_get_referer() { |
| 1447 | - if ( ! function_exists( 'wp_validate_redirect' ) ) |
|
| 1448 | - return false; |
|
| 1506 | + if ( ! function_exists( 'wp_validate_redirect' ) ) { |
|
| 1507 | + return false; |
|
| 1508 | + } |
|
| 1449 | 1509 | $ref = false; |
| 1450 | - if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) |
|
| 1451 | - $ref = wp_unslash( $_REQUEST['_wp_http_referer'] ); |
|
| 1452 | - elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) |
|
| 1453 | - $ref = wp_unslash( $_SERVER['HTTP_REFERER'] ); |
|
| 1510 | + if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
|
| 1511 | + $ref = wp_unslash( $_REQUEST['_wp_http_referer'] ); |
|
| 1512 | + } elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { |
|
| 1513 | + $ref = wp_unslash( $_SERVER['HTTP_REFERER'] ); |
|
| 1514 | + } |
|
| 1454 | 1515 | |
| 1455 | - if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) ) |
|
| 1456 | - return wp_validate_redirect( $ref, false ); |
|
| 1516 | + if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) ) { |
|
| 1517 | + return wp_validate_redirect( $ref, false ); |
|
| 1518 | + } |
|
| 1457 | 1519 | return false; |
| 1458 | 1520 | } |
| 1459 | 1521 | |
@@ -1465,8 +1527,9 @@ discard block |
||
| 1465 | 1527 | * @return string|false False if no original referer or original referer if set. |
| 1466 | 1528 | */ |
| 1467 | 1529 | function wp_get_original_referer() { |
| 1468 | - if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) |
|
| 1469 | - return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); |
|
| 1530 | + if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) { |
|
| 1531 | + return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); |
|
| 1532 | + } |
|
| 1470 | 1533 | return false; |
| 1471 | 1534 | } |
| 1472 | 1535 | |
@@ -1501,11 +1564,13 @@ discard block |
||
| 1501 | 1564 | * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. |
| 1502 | 1565 | */ |
| 1503 | 1566 | $target = rtrim($target, '/'); |
| 1504 | - if ( empty($target) ) |
|
| 1505 | - $target = '/'; |
|
| 1567 | + if ( empty($target) ) { |
|
| 1568 | + $target = '/'; |
|
| 1569 | + } |
|
| 1506 | 1570 | |
| 1507 | - if ( file_exists( $target ) ) |
|
| 1508 | - return @is_dir( $target ); |
|
| 1571 | + if ( file_exists( $target ) ) { |
|
| 1572 | + return @is_dir( $target ); |
|
| 1573 | + } |
|
| 1509 | 1574 | |
| 1510 | 1575 | // We need to find the permissions of the parent folder that exists and inherit that. |
| 1511 | 1576 | $target_parent = dirname( $target ); |
@@ -1554,15 +1619,18 @@ discard block |
||
| 1554 | 1619 | * This is definitive if true but fails if $path does not exist or contains |
| 1555 | 1620 | * a symbolic link. |
| 1556 | 1621 | */ |
| 1557 | - if ( realpath($path) == $path ) |
|
| 1558 | - return true; |
|
| 1622 | + if ( realpath($path) == $path ) { |
|
| 1623 | + return true; |
|
| 1624 | + } |
|
| 1559 | 1625 | |
| 1560 | - if ( strlen($path) == 0 || $path[0] == '.' ) |
|
| 1561 | - return false; |
|
| 1626 | + if ( strlen($path) == 0 || $path[0] == '.' ) { |
|
| 1627 | + return false; |
|
| 1628 | + } |
|
| 1562 | 1629 | |
| 1563 | 1630 | // Windows allows absolute paths like this. |
| 1564 | - if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) |
|
| 1565 | - return true; |
|
| 1631 | + if ( preg_match('#^[a-zA-Z]:\\\\#', $path) ) { |
|
| 1632 | + return true; |
|
| 1633 | + } |
|
| 1566 | 1634 | |
| 1567 | 1635 | // A path starting with / or \ is absolute; anything else is relative. |
| 1568 | 1636 | return ( $path[0] == '/' || $path[0] == '\\' ); |
@@ -1581,8 +1649,9 @@ discard block |
||
| 1581 | 1649 | * @return string The path with the base or absolute path. |
| 1582 | 1650 | */ |
| 1583 | 1651 | function path_join( $base, $path ) { |
| 1584 | - if ( path_is_absolute($path) ) |
|
| 1585 | - return $path; |
|
| 1652 | + if ( path_is_absolute($path) ) { |
|
| 1653 | + return $path; |
|
| 1654 | + } |
|
| 1586 | 1655 | |
| 1587 | 1656 | return rtrim($base, '/') . '/' . ltrim($path, '/'); |
| 1588 | 1657 | } |
@@ -1622,25 +1691,30 @@ discard block |
||
| 1622 | 1691 | */ |
| 1623 | 1692 | function get_temp_dir() { |
| 1624 | 1693 | static $temp = ''; |
| 1625 | - if ( defined('WP_TEMP_DIR') ) |
|
| 1626 | - return trailingslashit(WP_TEMP_DIR); |
|
| 1694 | + if ( defined('WP_TEMP_DIR') ) { |
|
| 1695 | + return trailingslashit(WP_TEMP_DIR); |
|
| 1696 | + } |
|
| 1627 | 1697 | |
| 1628 | - if ( $temp ) |
|
| 1629 | - return trailingslashit( $temp ); |
|
| 1698 | + if ( $temp ) { |
|
| 1699 | + return trailingslashit( $temp ); |
|
| 1700 | + } |
|
| 1630 | 1701 | |
| 1631 | 1702 | if ( function_exists('sys_get_temp_dir') ) { |
| 1632 | 1703 | $temp = sys_get_temp_dir(); |
| 1633 | - if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1634 | - return trailingslashit( $temp ); |
|
| 1704 | + if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { |
|
| 1705 | + return trailingslashit( $temp ); |
|
| 1706 | + } |
|
| 1635 | 1707 | } |
| 1636 | 1708 | |
| 1637 | 1709 | $temp = ini_get('upload_tmp_dir'); |
| 1638 | - if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1639 | - return trailingslashit( $temp ); |
|
| 1710 | + if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { |
|
| 1711 | + return trailingslashit( $temp ); |
|
| 1712 | + } |
|
| 1640 | 1713 | |
| 1641 | 1714 | $temp = WP_CONTENT_DIR . '/'; |
| 1642 | - if ( is_dir( $temp ) && wp_is_writable( $temp ) ) |
|
| 1643 | - return $temp; |
|
| 1715 | + if ( is_dir( $temp ) && wp_is_writable( $temp ) ) { |
|
| 1716 | + return $temp; |
|
| 1717 | + } |
|
| 1644 | 1718 | |
| 1645 | 1719 | return '/tmp/'; |
| 1646 | 1720 | } |
@@ -1659,11 +1733,12 @@ discard block |
||
| 1659 | 1733 | * @return bool Whether the path is writable. |
| 1660 | 1734 | */ |
| 1661 | 1735 | function wp_is_writable( $path ) { |
| 1662 | - if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) |
|
| 1663 | - return win_is_writable( $path ); |
|
| 1664 | - else |
|
| 1665 | - return @is_writable( $path ); |
|
| 1666 | -} |
|
| 1736 | + if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) { |
|
| 1737 | + return win_is_writable( $path ); |
|
| 1738 | + } else { |
|
| 1739 | + return @is_writable( $path ); |
|
| 1740 | + } |
|
| 1741 | + } |
|
| 1667 | 1742 | |
| 1668 | 1743 | /** |
| 1669 | 1744 | * Workaround for Windows bug in is_writable() function |
@@ -1691,11 +1766,13 @@ discard block |
||
| 1691 | 1766 | // check tmp file for read/write capabilities |
| 1692 | 1767 | $should_delete_tmp_file = !file_exists( $path ); |
| 1693 | 1768 | $f = @fopen( $path, 'a' ); |
| 1694 | - if ( $f === false ) |
|
| 1695 | - return false; |
|
| 1769 | + if ( $f === false ) { |
|
| 1770 | + return false; |
|
| 1771 | + } |
|
| 1696 | 1772 | fclose( $f ); |
| 1697 | - if ( $should_delete_tmp_file ) |
|
| 1698 | - unlink( $path ); |
|
| 1773 | + if ( $should_delete_tmp_file ) { |
|
| 1774 | + unlink( $path ); |
|
| 1775 | + } |
|
| 1699 | 1776 | return true; |
| 1700 | 1777 | } |
| 1701 | 1778 | |
@@ -1745,10 +1822,11 @@ discard block |
||
| 1745 | 1822 | } |
| 1746 | 1823 | |
| 1747 | 1824 | if ( !$url = get_option( 'upload_url_path' ) ) { |
| 1748 | - if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) |
|
| 1749 | - $url = WP_CONTENT_URL . '/uploads'; |
|
| 1750 | - else |
|
| 1751 | - $url = trailingslashit( $siteurl ) . $upload_path; |
|
| 1825 | + if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) { |
|
| 1826 | + $url = WP_CONTENT_URL . '/uploads'; |
|
| 1827 | + } else { |
|
| 1828 | + $url = trailingslashit( $siteurl ) . $upload_path; |
|
| 1829 | + } |
|
| 1752 | 1830 | } |
| 1753 | 1831 | |
| 1754 | 1832 | /* |
@@ -1773,10 +1851,11 @@ discard block |
||
| 1773 | 1851 | * had wp-content/uploads for the main site.) |
| 1774 | 1852 | */ |
| 1775 | 1853 | |
| 1776 | - if ( defined( 'MULTISITE' ) ) |
|
| 1777 | - $ms_dir = '/sites/' . get_current_blog_id(); |
|
| 1778 | - else |
|
| 1779 | - $ms_dir = '/' . get_current_blog_id(); |
|
| 1854 | + if ( defined( 'MULTISITE' ) ) { |
|
| 1855 | + $ms_dir = '/sites/' . get_current_blog_id(); |
|
| 1856 | + } else { |
|
| 1857 | + $ms_dir = '/' . get_current_blog_id(); |
|
| 1858 | + } |
|
| 1780 | 1859 | |
| 1781 | 1860 | $dir .= $ms_dir; |
| 1782 | 1861 | $url .= $ms_dir; |
@@ -1796,10 +1875,11 @@ discard block |
||
| 1796 | 1875 | * rewriting in multisite, the resulting URL is /files. (#WP22702 for background.) |
| 1797 | 1876 | */ |
| 1798 | 1877 | |
| 1799 | - if ( defined( 'BLOGUPLOADDIR' ) ) |
|
| 1800 | - $dir = untrailingslashit( BLOGUPLOADDIR ); |
|
| 1801 | - else |
|
| 1802 | - $dir = ABSPATH . UPLOADS; |
|
| 1878 | + if ( defined( 'BLOGUPLOADDIR' ) ) { |
|
| 1879 | + $dir = untrailingslashit( BLOGUPLOADDIR ); |
|
| 1880 | + } else { |
|
| 1881 | + $dir = ABSPATH . UPLOADS; |
|
| 1882 | + } |
|
| 1803 | 1883 | $url = trailingslashit( $siteurl ) . 'files'; |
| 1804 | 1884 | } |
| 1805 | 1885 | } |
@@ -1810,8 +1890,9 @@ discard block |
||
| 1810 | 1890 | $subdir = ''; |
| 1811 | 1891 | if ( get_option( 'uploads_use_yearmonth_folders' ) ) { |
| 1812 | 1892 | // Generate the yearly and monthly dirs |
| 1813 | - if ( !$time ) |
|
| 1814 | - $time = current_time( 'mysql' ); |
|
| 1893 | + if ( !$time ) { |
|
| 1894 | + $time = current_time( 'mysql' ); |
|
| 1895 | + } |
|
| 1815 | 1896 | $y = substr( $time, 0, 4 ); |
| 1816 | 1897 | $m = substr( $time, 5, 2 ); |
| 1817 | 1898 | $subdir = "/$y/$m"; |
@@ -1840,10 +1921,11 @@ discard block |
||
| 1840 | 1921 | |
| 1841 | 1922 | // Make sure we have an uploads directory. |
| 1842 | 1923 | if ( ! wp_mkdir_p( $uploads['path'] ) ) { |
| 1843 | - if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) |
|
| 1844 | - $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1845 | - else |
|
| 1846 | - $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1924 | + if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { |
|
| 1925 | + $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1926 | + } else { |
|
| 1927 | + $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; |
|
| 1928 | + } |
|
| 1847 | 1929 | |
| 1848 | 1930 | $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); |
| 1849 | 1931 | $uploads['error'] = $message; |
@@ -1879,8 +1961,9 @@ discard block |
||
| 1879 | 1961 | $name = basename($filename, $ext); |
| 1880 | 1962 | |
| 1881 | 1963 | // Edge case: if file is named '.ext', treat as an empty name. |
| 1882 | - if ( $name === $ext ) |
|
| 1883 | - $name = ''; |
|
| 1964 | + if ( $name === $ext ) { |
|
| 1965 | + $name = ''; |
|
| 1966 | + } |
|
| 1884 | 1967 | |
| 1885 | 1968 | /* |
| 1886 | 1969 | * Increment the file number until we have a unique file to save in $dir. |
@@ -1907,10 +1990,11 @@ discard block |
||
| 1907 | 1990 | } |
| 1908 | 1991 | |
| 1909 | 1992 | while ( file_exists( $dir . "/$filename" ) ) { |
| 1910 | - if ( '' == "$number$ext" ) |
|
| 1911 | - $filename = $filename . ++$number . $ext; |
|
| 1912 | - else |
|
| 1913 | - $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); |
|
| 1993 | + if ( '' == "$number$ext" ) { |
|
| 1994 | + $filename = $filename . ++$number . $ext; |
|
| 1995 | + } else { |
|
| 1996 | + $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); |
|
| 1997 | + } |
|
| 1914 | 1998 | } |
| 1915 | 1999 | } |
| 1916 | 2000 | |
@@ -1941,20 +2025,24 @@ discard block |
||
| 1941 | 2025 | * @return array |
| 1942 | 2026 | */ |
| 1943 | 2027 | function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { |
| 1944 | - if ( !empty( $deprecated ) ) |
|
| 1945 | - _deprecated_argument( __FUNCTION__, '2.0' ); |
|
| 2028 | + if ( !empty( $deprecated ) ) { |
|
| 2029 | + _deprecated_argument( __FUNCTION__, '2.0' ); |
|
| 2030 | + } |
|
| 1946 | 2031 | |
| 1947 | - if ( empty( $name ) ) |
|
| 1948 | - return array( 'error' => __( 'Empty filename' ) ); |
|
| 2032 | + if ( empty( $name ) ) { |
|
| 2033 | + return array( 'error' => __( 'Empty filename' ) ); |
|
| 2034 | + } |
|
| 1949 | 2035 | |
| 1950 | 2036 | $wp_filetype = wp_check_filetype( $name ); |
| 1951 | - if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) |
|
| 1952 | - return array( 'error' => __( 'Invalid file type' ) ); |
|
| 2037 | + if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) { |
|
| 2038 | + return array( 'error' => __( 'Invalid file type' ) ); |
|
| 2039 | + } |
|
| 1953 | 2040 | |
| 1954 | 2041 | $upload = wp_upload_dir( $time ); |
| 1955 | 2042 | |
| 1956 | - if ( $upload['error'] !== false ) |
|
| 1957 | - return $upload; |
|
| 2043 | + if ( $upload['error'] !== false ) { |
|
| 2044 | + return $upload; |
|
| 2045 | + } |
|
| 1958 | 2046 | |
| 1959 | 2047 | /** |
| 1960 | 2048 | * Filter whether to treat the upload bits as an error. |
@@ -1976,18 +2064,20 @@ discard block |
||
| 1976 | 2064 | |
| 1977 | 2065 | $new_file = $upload['path'] . "/$filename"; |
| 1978 | 2066 | if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { |
| 1979 | - if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) |
|
| 1980 | - $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; |
|
| 1981 | - else |
|
| 1982 | - $error_path = basename( $upload['basedir'] ) . $upload['subdir']; |
|
| 2067 | + if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) { |
|
| 2068 | + $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; |
|
| 2069 | + } else { |
|
| 2070 | + $error_path = basename( $upload['basedir'] ) . $upload['subdir']; |
|
| 2071 | + } |
|
| 1983 | 2072 | |
| 1984 | 2073 | $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $error_path ); |
| 1985 | 2074 | return array( 'error' => $message ); |
| 1986 | 2075 | } |
| 1987 | 2076 | |
| 1988 | 2077 | $ifp = @ fopen( $new_file, 'wb' ); |
| 1989 | - if ( ! $ifp ) |
|
| 1990 | - return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); |
|
| 2078 | + if ( ! $ifp ) { |
|
| 2079 | + return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); |
|
| 2080 | + } |
|
| 1991 | 2081 | |
| 1992 | 2082 | @fwrite( $ifp, $bits ); |
| 1993 | 2083 | fclose( $ifp ); |
@@ -2039,10 +2129,11 @@ discard block |
||
| 2039 | 2129 | 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), |
| 2040 | 2130 | ) ); |
| 2041 | 2131 | |
| 2042 | - foreach ( $ext2type as $type => $exts ) |
|
| 2043 | - if ( in_array( $ext, $exts ) ) |
|
| 2132 | + foreach ( $ext2type as $type => $exts ) { |
|
| 2133 | + if ( in_array( $ext, $exts ) ) |
|
| 2044 | 2134 | return $type; |
| 2045 | -} |
|
| 2135 | + } |
|
| 2136 | + } |
|
| 2046 | 2137 | |
| 2047 | 2138 | /** |
| 2048 | 2139 | * Retrieve the file type from the file name. |
@@ -2056,8 +2147,9 @@ discard block |
||
| 2056 | 2147 | * @return array Values with extension first and mime type. |
| 2057 | 2148 | */ |
| 2058 | 2149 | function wp_check_filetype( $filename, $mimes = null ) { |
| 2059 | - if ( empty($mimes) ) |
|
| 2060 | - $mimes = get_allowed_mime_types(); |
|
| 2150 | + if ( empty($mimes) ) { |
|
| 2151 | + $mimes = get_allowed_mime_types(); |
|
| 2152 | + } |
|
| 2061 | 2153 | $type = false; |
| 2062 | 2154 | $ext = false; |
| 2063 | 2155 | |
@@ -2296,11 +2388,13 @@ discard block |
||
| 2296 | 2388 | $t = wp_get_mime_types(); |
| 2297 | 2389 | |
| 2298 | 2390 | unset( $t['swf'], $t['exe'] ); |
| 2299 | - if ( function_exists( 'current_user_can' ) ) |
|
| 2300 | - $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); |
|
| 2391 | + if ( function_exists( 'current_user_can' ) ) { |
|
| 2392 | + $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); |
|
| 2393 | + } |
|
| 2301 | 2394 | |
| 2302 | - if ( empty( $unfiltered ) ) |
|
| 2303 | - unset( $t['htm|html'] ); |
|
| 2395 | + if ( empty( $unfiltered ) ) { |
|
| 2396 | + unset( $t['htm|html'] ); |
|
| 2397 | + } |
|
| 2304 | 2398 | |
| 2305 | 2399 | /** |
| 2306 | 2400 | * Filter list of allowed mime types and file extensions. |
@@ -2332,8 +2426,9 @@ discard block |
||
| 2332 | 2426 | $html .= sprintf( __( "Do you really want to <a href='%s'>log out</a>?"), wp_logout_url( $redirect_to ) ); |
| 2333 | 2427 | } else { |
| 2334 | 2428 | $html = __( 'Are you sure you want to do this?' ); |
| 2335 | - if ( wp_get_referer() ) |
|
| 2336 | - $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; |
|
| 2429 | + if ( wp_get_referer() ) { |
|
| 2430 | + $html .= "</p><p><a href='" . esc_url( remove_query_arg( 'updated', wp_get_referer() ) ) . "'>" . __( 'Please try again.' ) . "</a>"; |
|
| 2431 | + } |
|
| 2337 | 2432 | } |
| 2338 | 2433 | |
| 2339 | 2434 | wp_die( $html, __( 'WordPress Failure Notice' ), 403 ); |
@@ -2435,8 +2530,9 @@ discard block |
||
| 2435 | 2530 | if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { |
| 2436 | 2531 | if ( empty( $title ) ) { |
| 2437 | 2532 | $error_data = $message->get_error_data(); |
| 2438 | - if ( is_array( $error_data ) && isset( $error_data['title'] ) ) |
|
| 2439 | - $title = $error_data['title']; |
|
| 2533 | + if ( is_array( $error_data ) && isset( $error_data['title'] ) ) { |
|
| 2534 | + $title = $error_data['title']; |
|
| 2535 | + } |
|
| 2440 | 2536 | } |
| 2441 | 2537 | $errors = $message->get_error_messages(); |
| 2442 | 2538 | switch ( count( $errors ) ) { |
@@ -2466,19 +2562,26 @@ discard block |
||
| 2466 | 2562 | header( 'Content-Type: text/html; charset=utf-8' ); |
| 2467 | 2563 | } |
| 2468 | 2564 | |
| 2469 | - if ( empty($title) ) |
|
| 2470 | - $title = $have_gettext ? __('WordPress › Error') : 'WordPress › Error'; |
|
| 2565 | + if ( empty($title) ) { |
|
| 2566 | + $title = $have_gettext ? __('WordPress › Error') : 'WordPress › Error'; |
|
| 2567 | + } |
|
| 2471 | 2568 | |
| 2472 | 2569 | $text_direction = 'ltr'; |
| 2473 | - if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] ) |
|
| 2474 | - $text_direction = 'rtl'; |
|
| 2475 | - elseif ( function_exists( 'is_rtl' ) && is_rtl() ) |
|
| 2476 | - $text_direction = 'rtl'; |
|
| 2477 | -?> |
|
| 2570 | + if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] ) { |
|
| 2571 | + $text_direction = 'rtl'; |
|
| 2572 | + } elseif ( function_exists( 'is_rtl' ) && is_rtl() ) { |
|
| 2573 | + $text_direction = 'rtl'; |
|
| 2574 | + } |
|
| 2575 | + ?> |
|
| 2478 | 2576 | <!DOCTYPE html> |
| 2479 | 2577 | <!-- Ticket #11289, IE bug fix: always pad the error page with enough characters such that it is greater than 512 bytes, even after gzip compression abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono |
| 2480 | 2578 | --> |
| 2481 | -<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) language_attributes(); else echo "dir='$text_direction'"; ?>> |
|
| 2579 | +<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { |
|
| 2580 | + language_attributes(); |
|
| 2581 | +} else { |
|
| 2582 | + echo "dir='$text_direction'"; |
|
| 2583 | +} |
|
| 2584 | +?>> |
|
| 2482 | 2585 | <head> |
| 2483 | 2586 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 2484 | 2587 | <meta name="viewport" content="width=device-width"> |
@@ -2631,8 +2734,9 @@ discard block |
||
| 2631 | 2734 | * @param string $message Optional. Response to print. Default empty. |
| 2632 | 2735 | */ |
| 2633 | 2736 | function _ajax_wp_die_handler( $message = '' ) { |
| 2634 | - if ( is_scalar( $message ) ) |
|
| 2635 | - die( (string) $message ); |
|
| 2737 | + if ( is_scalar( $message ) ) { |
|
| 2738 | + die( (string) $message ); |
|
| 2739 | + } |
|
| 2636 | 2740 | die( '0' ); |
| 2637 | 2741 | } |
| 2638 | 2742 | |
@@ -2647,8 +2751,9 @@ discard block |
||
| 2647 | 2751 | * @param string $message Optional. Response to print. Default empty. |
| 2648 | 2752 | */ |
| 2649 | 2753 | function _scalar_wp_die_handler( $message = '' ) { |
| 2650 | - if ( is_scalar( $message ) ) |
|
| 2651 | - die( (string) $message ); |
|
| 2754 | + if ( is_scalar( $message ) ) { |
|
| 2755 | + die( (string) $message ); |
|
| 2756 | + } |
|
| 2652 | 2757 | die(); |
| 2653 | 2758 | } |
| 2654 | 2759 | |
@@ -2801,11 +2906,12 @@ discard block |
||
| 2801 | 2906 | function wp_send_json( $response ) { |
| 2802 | 2907 | @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); |
| 2803 | 2908 | echo wp_json_encode( $response ); |
| 2804 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
| 2805 | - wp_die(); |
|
| 2806 | - else |
|
| 2807 | - die; |
|
| 2808 | -} |
|
| 2909 | + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 2910 | + wp_die(); |
|
| 2911 | + } else { |
|
| 2912 | + die; |
|
| 2913 | + } |
|
| 2914 | + } |
|
| 2809 | 2915 | |
| 2810 | 2916 | /** |
| 2811 | 2917 | * Send a JSON response back to an Ajax request, indicating success. |
@@ -2817,8 +2923,9 @@ discard block |
||
| 2817 | 2923 | function wp_send_json_success( $data = null ) { |
| 2818 | 2924 | $response = array( 'success' => true ); |
| 2819 | 2925 | |
| 2820 | - if ( isset( $data ) ) |
|
| 2821 | - $response['data'] = $data; |
|
| 2926 | + if ( isset( $data ) ) { |
|
| 2927 | + $response['data'] = $data; |
|
| 2928 | + } |
|
| 2822 | 2929 | |
| 2823 | 2930 | wp_send_json( $response ); |
| 2824 | 2931 | } |
@@ -2874,8 +2981,9 @@ discard block |
||
| 2874 | 2981 | * @return string Homepage location. |
| 2875 | 2982 | */ |
| 2876 | 2983 | function _config_wp_home( $url = '' ) { |
| 2877 | - if ( defined( 'WP_HOME' ) ) |
|
| 2878 | - return untrailingslashit( WP_HOME ); |
|
| 2984 | + if ( defined( 'WP_HOME' ) ) { |
|
| 2985 | + return untrailingslashit( WP_HOME ); |
|
| 2986 | + } |
|
| 2879 | 2987 | return $url; |
| 2880 | 2988 | } |
| 2881 | 2989 | |
@@ -2895,8 +3003,9 @@ discard block |
||
| 2895 | 3003 | * @return string The WordPress Site URL. |
| 2896 | 3004 | */ |
| 2897 | 3005 | function _config_wp_siteurl( $url = '' ) { |
| 2898 | - if ( defined( 'WP_SITEURL' ) ) |
|
| 2899 | - return untrailingslashit( WP_SITEURL ); |
|
| 3006 | + if ( defined( 'WP_SITEURL' ) ) { |
|
| 3007 | + return untrailingslashit( WP_SITEURL ); |
|
| 3008 | + } |
|
| 2900 | 3009 | return $url; |
| 2901 | 3010 | } |
| 2902 | 3011 | |
@@ -2960,8 +3069,9 @@ discard block |
||
| 2960 | 3069 | global $wpsmiliestrans, $wp_smiliessearch; |
| 2961 | 3070 | |
| 2962 | 3071 | // don't bother setting up smilies if they are disabled |
| 2963 | - if ( !get_option( 'use_smilies' ) ) |
|
| 2964 | - return; |
|
| 3072 | + if ( !get_option( 'use_smilies' ) ) { |
|
| 3073 | + return; |
|
| 3074 | + } |
|
| 2965 | 3075 | |
| 2966 | 3076 | if ( !isset( $wpsmiliestrans ) ) { |
| 2967 | 3077 | $wpsmiliestrans = array( |
@@ -3065,15 +3175,17 @@ discard block |
||
| 3065 | 3175 | * @return array Merged user defined values with defaults. |
| 3066 | 3176 | */ |
| 3067 | 3177 | function wp_parse_args( $args, $defaults = '' ) { |
| 3068 | - if ( is_object( $args ) ) |
|
| 3069 | - $r = get_object_vars( $args ); |
|
| 3070 | - elseif ( is_array( $args ) ) |
|
| 3071 | - $r =& $args; |
|
| 3072 | - else |
|
| 3073 | - wp_parse_str( $args, $r ); |
|
| 3074 | - |
|
| 3075 | - if ( is_array( $defaults ) ) |
|
| 3076 | - return array_merge( $defaults, $r ); |
|
| 3178 | + if ( is_object( $args ) ) { |
|
| 3179 | + $r = get_object_vars( $args ); |
|
| 3180 | + } elseif ( is_array( $args ) ) { |
|
| 3181 | + $r =& $args; |
|
| 3182 | + } else { |
|
| 3183 | + wp_parse_str( $args, $r ); |
|
| 3184 | + } |
|
| 3185 | + |
|
| 3186 | + if ( is_array( $defaults ) ) { |
|
| 3187 | + return array_merge( $defaults, $r ); |
|
| 3188 | + } |
|
| 3077 | 3189 | return $r; |
| 3078 | 3190 | } |
| 3079 | 3191 | |
@@ -3086,8 +3198,9 @@ discard block |
||
| 3086 | 3198 | * @return array Sanitized array of IDs. |
| 3087 | 3199 | */ |
| 3088 | 3200 | function wp_parse_id_list( $list ) { |
| 3089 | - if ( !is_array($list) ) |
|
| 3090 | - $list = preg_split('/[\s,]+/', $list); |
|
| 3201 | + if ( !is_array($list) ) { |
|
| 3202 | + $list = preg_split('/[\s,]+/', $list); |
|
| 3203 | + } |
|
| 3091 | 3204 | |
| 3092 | 3205 | return array_unique(array_map('absint', $list)); |
| 3093 | 3206 | } |
@@ -3103,9 +3216,10 @@ discard block |
||
| 3103 | 3216 | */ |
| 3104 | 3217 | function wp_array_slice_assoc( $array, $keys ) { |
| 3105 | 3218 | $slice = array(); |
| 3106 | - foreach ( $keys as $key ) |
|
| 3107 | - if ( isset( $array[ $key ] ) ) |
|
| 3219 | + foreach ( $keys as $key ) { |
|
| 3220 | + if ( isset( $array[ $key ] ) ) |
|
| 3108 | 3221 | $slice[ $key ] = $array[ $key ]; |
| 3222 | + } |
|
| 3109 | 3223 | |
| 3110 | 3224 | return $slice; |
| 3111 | 3225 | } |
@@ -3126,13 +3240,15 @@ discard block |
||
| 3126 | 3240 | * @return array A list of objects or object fields. |
| 3127 | 3241 | */ |
| 3128 | 3242 | function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { |
| 3129 | - if ( ! is_array( $list ) ) |
|
| 3130 | - return array(); |
|
| 3243 | + if ( ! is_array( $list ) ) { |
|
| 3244 | + return array(); |
|
| 3245 | + } |
|
| 3131 | 3246 | |
| 3132 | 3247 | $list = wp_list_filter( $list, $args, $operator ); |
| 3133 | 3248 | |
| 3134 | - if ( $field ) |
|
| 3135 | - $list = wp_list_pluck( $list, $field ); |
|
| 3249 | + if ( $field ) { |
|
| 3250 | + $list = wp_list_pluck( $list, $field ); |
|
| 3251 | + } |
|
| 3136 | 3252 | |
| 3137 | 3253 | return $list; |
| 3138 | 3254 | } |
@@ -3152,11 +3268,13 @@ discard block |
||
| 3152 | 3268 | * @return array Array of found values. |
| 3153 | 3269 | */ |
| 3154 | 3270 | function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { |
| 3155 | - if ( ! is_array( $list ) ) |
|
| 3156 | - return array(); |
|
| 3271 | + if ( ! is_array( $list ) ) { |
|
| 3272 | + return array(); |
|
| 3273 | + } |
|
| 3157 | 3274 | |
| 3158 | - if ( empty( $args ) ) |
|
| 3159 | - return $list; |
|
| 3275 | + if ( empty( $args ) ) { |
|
| 3276 | + return $list; |
|
| 3277 | + } |
|
| 3160 | 3278 | |
| 3161 | 3279 | $operator = strtoupper( $operator ); |
| 3162 | 3280 | $count = count( $args ); |
@@ -3167,8 +3285,9 @@ discard block |
||
| 3167 | 3285 | |
| 3168 | 3286 | $matched = 0; |
| 3169 | 3287 | foreach ( $args as $m_key => $m_value ) { |
| 3170 | - if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) |
|
| 3171 | - $matched++; |
|
| 3288 | + if ( array_key_exists( $m_key, $to_match ) && $m_value == $to_match[ $m_key ] ) { |
|
| 3289 | + $matched++; |
|
| 3290 | + } |
|
| 3172 | 3291 | } |
| 3173 | 3292 | |
| 3174 | 3293 | if ( ( 'AND' == $operator && $matched == $count ) |
@@ -3277,8 +3396,9 @@ discard block |
||
| 3277 | 3396 | function wp_widgets_add_menu() { |
| 3278 | 3397 | global $submenu; |
| 3279 | 3398 | |
| 3280 | - if ( ! current_theme_supports( 'widgets' ) ) |
|
| 3281 | - return; |
|
| 3399 | + if ( ! current_theme_supports( 'widgets' ) ) { |
|
| 3400 | + return; |
|
| 3401 | + } |
|
| 3282 | 3402 | |
| 3283 | 3403 | $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); |
| 3284 | 3404 | ksort( $submenu['themes.php'], SORT_NUMERIC ); |
@@ -3293,9 +3413,10 @@ discard block |
||
| 3293 | 3413 | */ |
| 3294 | 3414 | function wp_ob_end_flush_all() { |
| 3295 | 3415 | $levels = ob_get_level(); |
| 3296 | - for ($i=0; $i<$levels; $i++) |
|
| 3297 | - ob_end_flush(); |
|
| 3298 | -} |
|
| 3416 | + for ($i=0; $i<$levels; $i++) { |
|
| 3417 | + ob_end_flush(); |
|
| 3418 | + } |
|
| 3419 | + } |
|
| 3299 | 3420 | |
| 3300 | 3421 | /** |
| 3301 | 3422 | * Load custom DB error or display WordPress DB error. |
@@ -3327,8 +3448,9 @@ discard block |
||
| 3327 | 3448 | } |
| 3328 | 3449 | |
| 3329 | 3450 | // If installing or in the admin, provide the verbose message. |
| 3330 | - if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) |
|
| 3331 | - wp_die($wpdb->error); |
|
| 3451 | + if ( defined('WP_INSTALLING') || defined('WP_ADMIN') ) { |
|
| 3452 | + wp_die($wpdb->error); |
|
| 3453 | + } |
|
| 3332 | 3454 | |
| 3333 | 3455 | // Otherwise, be terse. |
| 3334 | 3456 | status_header( 500 ); |
@@ -3336,7 +3458,10 @@ discard block |
||
| 3336 | 3458 | header( 'Content-Type: text/html; charset=utf-8' ); |
| 3337 | 3459 | ?> |
| 3338 | 3460 | <!DOCTYPE html> |
| 3339 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ' dir="rtl"'; ?>> |
|
| 3461 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) { |
|
| 3462 | + echo ' dir="rtl"'; |
|
| 3463 | +} |
|
| 3464 | +?>> |
|
| 3340 | 3465 | <head> |
| 3341 | 3466 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 3342 | 3467 | <title><?php _e( 'Database Error' ); ?></title> |
@@ -3402,15 +3527,17 @@ discard block |
||
| 3402 | 3527 | */ |
| 3403 | 3528 | if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { |
| 3404 | 3529 | if ( function_exists( '__' ) ) { |
| 3405 | - if ( ! is_null( $replacement ) ) |
|
| 3406 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) ); |
|
| 3407 | - else |
|
| 3408 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3530 | + if ( ! is_null( $replacement ) ) { |
|
| 3531 | + trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) ); |
|
| 3532 | + } else { |
|
| 3533 | + trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3534 | + } |
|
| 3409 | 3535 | } else { |
| 3410 | - if ( ! is_null( $replacement ) ) |
|
| 3411 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) ); |
|
| 3412 | - else |
|
| 3413 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3536 | + if ( ! is_null( $replacement ) ) { |
|
| 3537 | + trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) ); |
|
| 3538 | + } else { |
|
| 3539 | + trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3540 | + } |
|
| 3414 | 3541 | } |
| 3415 | 3542 | } |
| 3416 | 3543 | } |
@@ -3506,15 +3633,17 @@ discard block |
||
| 3506 | 3633 | if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { |
| 3507 | 3634 | $message = empty( $message ) ? '' : ' ' . $message; |
| 3508 | 3635 | if ( function_exists( '__' ) ) { |
| 3509 | - if ( ! is_null( $replacement ) ) |
|
| 3510 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message ); |
|
| 3511 | - else |
|
| 3512 | - trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message ); |
|
| 3636 | + if ( ! is_null( $replacement ) ) { |
|
| 3637 | + trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message ); |
|
| 3638 | + } else { |
|
| 3639 | + trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message ); |
|
| 3640 | + } |
|
| 3513 | 3641 | } else { |
| 3514 | - if ( ! is_null( $replacement ) ) |
|
| 3515 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message ); |
|
| 3516 | - else |
|
| 3517 | - trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message ); |
|
| 3642 | + if ( ! is_null( $replacement ) ) { |
|
| 3643 | + trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message ); |
|
| 3644 | + } else { |
|
| 3645 | + trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message ); |
|
| 3646 | + } |
|
| 3518 | 3647 | } |
| 3519 | 3648 | } |
| 3520 | 3649 | } |
@@ -3566,15 +3695,17 @@ discard block |
||
| 3566 | 3695 | */ |
| 3567 | 3696 | if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { |
| 3568 | 3697 | if ( function_exists( '__' ) ) { |
| 3569 | - if ( ! is_null( $message ) ) |
|
| 3570 | - trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) ); |
|
| 3571 | - else |
|
| 3572 | - trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3698 | + if ( ! is_null( $message ) ) { |
|
| 3699 | + trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) ); |
|
| 3700 | + } else { |
|
| 3701 | + trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
|
| 3702 | + } |
|
| 3573 | 3703 | } else { |
| 3574 | - if ( ! is_null( $message ) ) |
|
| 3575 | - trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) ); |
|
| 3576 | - else |
|
| 3577 | - trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3704 | + if ( ! is_null( $message ) ) { |
|
| 3705 | + trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) ); |
|
| 3706 | + } else { |
|
| 3707 | + trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
|
| 3708 | + } |
|
| 3578 | 3709 | } |
| 3579 | 3710 | } |
| 3580 | 3711 | } |
@@ -3655,19 +3786,22 @@ discard block |
||
| 3655 | 3786 | function apache_mod_loaded($mod, $default = false) { |
| 3656 | 3787 | global $is_apache; |
| 3657 | 3788 | |
| 3658 | - if ( !$is_apache ) |
|
| 3659 | - return false; |
|
| 3789 | + if ( !$is_apache ) { |
|
| 3790 | + return false; |
|
| 3791 | + } |
|
| 3660 | 3792 | |
| 3661 | 3793 | if ( function_exists( 'apache_get_modules' ) ) { |
| 3662 | 3794 | $mods = apache_get_modules(); |
| 3663 | - if ( in_array($mod, $mods) ) |
|
| 3664 | - return true; |
|
| 3795 | + if ( in_array($mod, $mods) ) { |
|
| 3796 | + return true; |
|
| 3797 | + } |
|
| 3665 | 3798 | } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { |
| 3666 | 3799 | ob_start(); |
| 3667 | 3800 | phpinfo(8); |
| 3668 | 3801 | $phpinfo = ob_get_clean(); |
| 3669 | - if ( false !== strpos($phpinfo, $mod) ) |
|
| 3670 | - return true; |
|
| 3802 | + if ( false !== strpos($phpinfo, $mod) ) { |
|
| 3803 | + return true; |
|
| 3804 | + } |
|
| 3671 | 3805 | } |
| 3672 | 3806 | return $default; |
| 3673 | 3807 | } |
@@ -3723,17 +3857,21 @@ discard block |
||
| 3723 | 3857 | * @return int 0 means nothing is wrong, greater than 0 means something was wrong. |
| 3724 | 3858 | */ |
| 3725 | 3859 | function validate_file( $file, $allowed_files = '' ) { |
| 3726 | - if ( false !== strpos( $file, '..' ) ) |
|
| 3727 | - return 1; |
|
| 3860 | + if ( false !== strpos( $file, '..' ) ) { |
|
| 3861 | + return 1; |
|
| 3862 | + } |
|
| 3728 | 3863 | |
| 3729 | - if ( false !== strpos( $file, './' ) ) |
|
| 3730 | - return 1; |
|
| 3864 | + if ( false !== strpos( $file, './' ) ) { |
|
| 3865 | + return 1; |
|
| 3866 | + } |
|
| 3731 | 3867 | |
| 3732 | - if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) |
|
| 3733 | - return 3; |
|
| 3868 | + if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) { |
|
| 3869 | + return 3; |
|
| 3870 | + } |
|
| 3734 | 3871 | |
| 3735 | - if (':' == substr( $file, 1, 1 ) ) |
|
| 3736 | - return 2; |
|
| 3872 | + if (':' == substr( $file, 1, 1 ) ) { |
|
| 3873 | + return 2; |
|
| 3874 | + } |
|
| 3737 | 3875 | |
| 3738 | 3876 | return 0; |
| 3739 | 3877 | } |
@@ -3747,10 +3885,12 @@ discard block |
||
| 3747 | 3885 | */ |
| 3748 | 3886 | function is_ssl() { |
| 3749 | 3887 | if ( isset($_SERVER['HTTPS']) ) { |
| 3750 | - if ( 'on' == strtolower($_SERVER['HTTPS']) ) |
|
| 3751 | - return true; |
|
| 3752 | - if ( '1' == $_SERVER['HTTPS'] ) |
|
| 3753 | - return true; |
|
| 3888 | + if ( 'on' == strtolower($_SERVER['HTTPS']) ) { |
|
| 3889 | + return true; |
|
| 3890 | + } |
|
| 3891 | + if ( '1' == $_SERVER['HTTPS'] ) { |
|
| 3892 | + return true; |
|
| 3893 | + } |
|
| 3754 | 3894 | } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { |
| 3755 | 3895 | return true; |
| 3756 | 3896 | } |
@@ -3862,8 +4002,9 @@ discard block |
||
| 3862 | 4002 | function wp_suspend_cache_addition( $suspend = null ) { |
| 3863 | 4003 | static $_suspend = false; |
| 3864 | 4004 | |
| 3865 | - if ( is_bool( $suspend ) ) |
|
| 3866 | - $_suspend = $suspend; |
|
| 4005 | + if ( is_bool( $suspend ) ) { |
|
| 4006 | + $_suspend = $suspend; |
|
| 4007 | + } |
|
| 3867 | 4008 | |
| 3868 | 4009 | return $_suspend; |
| 3869 | 4010 | } |
@@ -3906,11 +4047,13 @@ discard block |
||
| 3906 | 4047 | // This is the current network's information; 'site' is old terminology. |
| 3907 | 4048 | global $current_site; |
| 3908 | 4049 | |
| 3909 | - if ( ! is_multisite() ) |
|
| 3910 | - return true; |
|
| 4050 | + if ( ! is_multisite() ) { |
|
| 4051 | + return true; |
|
| 4052 | + } |
|
| 3911 | 4053 | |
| 3912 | - if ( ! $site_id ) |
|
| 3913 | - $site_id = get_current_blog_id(); |
|
| 4054 | + if ( ! $site_id ) { |
|
| 4055 | + $site_id = get_current_blog_id(); |
|
| 4056 | + } |
|
| 3914 | 4057 | |
| 3915 | 4058 | return (int) $site_id === (int) $current_site->blog_id; |
| 3916 | 4059 | } |
@@ -3989,8 +4132,9 @@ discard block |
||
| 3989 | 4132 | * @return bool True if multisite and global terms enabled. |
| 3990 | 4133 | */ |
| 3991 | 4134 | function global_terms_enabled() { |
| 3992 | - if ( ! is_multisite() ) |
|
| 3993 | - return false; |
|
| 4135 | + if ( ! is_multisite() ) { |
|
| 4136 | + return false; |
|
| 4137 | + } |
|
| 3994 | 4138 | |
| 3995 | 4139 | static $global_terms = null; |
| 3996 | 4140 | if ( is_null( $global_terms ) ) { |
@@ -4006,10 +4150,11 @@ discard block |
||
| 4006 | 4150 | * @param null $enabled Whether global terms are enabled. |
| 4007 | 4151 | */ |
| 4008 | 4152 | $filter = apply_filters( 'global_terms_enabled', null ); |
| 4009 | - if ( ! is_null( $filter ) ) |
|
| 4010 | - $global_terms = (bool) $filter; |
|
| 4011 | - else |
|
| 4012 | - $global_terms = (bool) get_site_option( 'global_terms_enabled', false ); |
|
| 4153 | + if ( ! is_null( $filter ) ) { |
|
| 4154 | + $global_terms = (bool) $filter; |
|
| 4155 | + } else { |
|
| 4156 | + $global_terms = (bool) get_site_option( 'global_terms_enabled', false ); |
|
| 4157 | + } |
|
| 4013 | 4158 | } |
| 4014 | 4159 | return $global_terms; |
| 4015 | 4160 | } |
@@ -4185,8 +4330,9 @@ discard block |
||
| 4185 | 4330 | // Do UTC |
| 4186 | 4331 | $structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">'; |
| 4187 | 4332 | $selected = ''; |
| 4188 | - if ( 'UTC' === $selected_zone ) |
|
| 4189 | - $selected = 'selected="selected" '; |
|
| 4333 | + if ( 'UTC' === $selected_zone ) { |
|
| 4334 | + $selected = 'selected="selected" '; |
|
| 4335 | + } |
|
| 4190 | 4336 | $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>'; |
| 4191 | 4337 | $structure[] = '</optgroup>'; |
| 4192 | 4338 | |
@@ -4195,18 +4341,20 @@ discard block |
||
| 4195 | 4341 | $offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, |
| 4196 | 4342 | 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14); |
| 4197 | 4343 | foreach ( $offset_range as $offset ) { |
| 4198 | - if ( 0 <= $offset ) |
|
| 4199 | - $offset_name = '+' . $offset; |
|
| 4200 | - else |
|
| 4201 | - $offset_name = (string) $offset; |
|
| 4344 | + if ( 0 <= $offset ) { |
|
| 4345 | + $offset_name = '+' . $offset; |
|
| 4346 | + } else { |
|
| 4347 | + $offset_name = (string) $offset; |
|
| 4348 | + } |
|
| 4202 | 4349 | |
| 4203 | 4350 | $offset_value = $offset_name; |
| 4204 | 4351 | $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name); |
| 4205 | 4352 | $offset_name = 'UTC' . $offset_name; |
| 4206 | 4353 | $offset_value = 'UTC' . $offset_value; |
| 4207 | 4354 | $selected = ''; |
| 4208 | - if ( $offset_value === $selected_zone ) |
|
| 4209 | - $selected = 'selected="selected" '; |
|
| 4355 | + if ( $offset_value === $selected_zone ) { |
|
| 4356 | + $selected = 'selected="selected" '; |
|
| 4357 | + } |
|
| 4210 | 4358 | $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>"; |
| 4211 | 4359 | |
| 4212 | 4360 | } |
@@ -4249,8 +4397,9 @@ discard block |
||
| 4249 | 4397 | |
| 4250 | 4398 | foreach ( (array) $posts_to_delete as $post ) { |
| 4251 | 4399 | $post_id = (int) $post['post_id']; |
| 4252 | - if ( !$post_id ) |
|
| 4253 | - continue; |
|
| 4400 | + if ( !$post_id ) { |
|
| 4401 | + continue; |
|
| 4402 | + } |
|
| 4254 | 4403 | |
| 4255 | 4404 | $del_post = get_post($post_id); |
| 4256 | 4405 | |
@@ -4266,8 +4415,9 @@ discard block |
||
| 4266 | 4415 | |
| 4267 | 4416 | foreach ( (array) $comments_to_delete as $comment ) { |
| 4268 | 4417 | $comment_id = (int) $comment['comment_id']; |
| 4269 | - if ( !$comment_id ) |
|
| 4270 | - continue; |
|
| 4418 | + if ( !$comment_id ) { |
|
| 4419 | + continue; |
|
| 4420 | + } |
|
| 4271 | 4421 | |
| 4272 | 4422 | $del_comment = get_comment($comment_id); |
| 4273 | 4423 | |
@@ -4331,10 +4481,11 @@ discard block |
||
| 4331 | 4481 | } |
| 4332 | 4482 | |
| 4333 | 4483 | foreach ( $all_headers as $field => $regex ) { |
| 4334 | - if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) |
|
| 4335 | - $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
|
| 4336 | - else |
|
| 4337 | - $all_headers[ $field ] = ''; |
|
| 4484 | + if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { |
|
| 4485 | + $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); |
|
| 4486 | + } else { |
|
| 4487 | + $all_headers[ $field ] = ''; |
|
| 4488 | + } |
|
| 4338 | 4489 | } |
| 4339 | 4490 | |
| 4340 | 4491 | return $all_headers; |
@@ -4477,8 +4628,9 @@ discard block |
||
| 4477 | 4628 | function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { |
| 4478 | 4629 | $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); |
| 4479 | 4630 | |
| 4480 | - if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) |
|
| 4481 | - return array(); |
|
| 4631 | + if ( !$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) { |
|
| 4632 | + return array(); |
|
| 4633 | + } |
|
| 4482 | 4634 | |
| 4483 | 4635 | return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); |
| 4484 | 4636 | } |
@@ -4516,12 +4668,14 @@ discard block |
||
| 4516 | 4668 | && |
| 4517 | 4669 | ( $hare = isset( $override[$evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) |
| 4518 | 4670 | ) { |
| 4519 | - if ( $_return_loop ) |
|
| 4520 | - $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; |
|
| 4671 | + if ( $_return_loop ) { |
|
| 4672 | + $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; |
|
| 4673 | + } |
|
| 4521 | 4674 | |
| 4522 | 4675 | // tortoise got lapped - must be a loop |
| 4523 | - if ( $tortoise == $evanescent_hare || $tortoise == $hare ) |
|
| 4524 | - return $_return_loop ? $return : $tortoise; |
|
| 4676 | + if ( $tortoise == $evanescent_hare || $tortoise == $hare ) { |
|
| 4677 | + return $_return_loop ? $return : $tortoise; |
|
| 4678 | + } |
|
| 4525 | 4679 | |
| 4526 | 4680 | // Increment tortoise by one step |
| 4527 | 4681 | $tortoise = isset( $override[$tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); |
@@ -4593,10 +4747,11 @@ discard block |
||
| 4593 | 4747 | * of individual calls. |
| 4594 | 4748 | */ |
| 4595 | 4749 | function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { |
| 4596 | - if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) |
|
| 4597 | - $trace = debug_backtrace( false ); |
|
| 4598 | - else |
|
| 4599 | - $trace = debug_backtrace(); |
|
| 4750 | + if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) { |
|
| 4751 | + $trace = debug_backtrace( false ); |
|
| 4752 | + } else { |
|
| 4753 | + $trace = debug_backtrace(); |
|
| 4754 | + } |
|
| 4600 | 4755 | |
| 4601 | 4756 | $caller = array(); |
| 4602 | 4757 | $check_class = ! is_null( $ignore_class ); |
@@ -4606,8 +4761,10 @@ discard block |
||
| 4606 | 4761 | if ( $skip_frames > 0 ) { |
| 4607 | 4762 | $skip_frames--; |
| 4608 | 4763 | } elseif ( isset( $call['class'] ) ) { |
| 4609 | - if ( $check_class && $ignore_class == $call['class'] ) |
|
| 4610 | - continue; // Filter out calls |
|
| 4764 | + if ( $check_class && $ignore_class == $call['class'] ) { |
|
| 4765 | + continue; |
|
| 4766 | + } |
|
| 4767 | + // Filter out calls |
|
| 4611 | 4768 | |
| 4612 | 4769 | $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; |
| 4613 | 4770 | } else { |
@@ -4620,11 +4777,12 @@ discard block |
||
| 4620 | 4777 | } |
| 4621 | 4778 | } |
| 4622 | 4779 | } |
| 4623 | - if ( $pretty ) |
|
| 4624 | - return join( ', ', array_reverse( $caller ) ); |
|
| 4625 | - else |
|
| 4626 | - return $caller; |
|
| 4627 | -} |
|
| 4780 | + if ( $pretty ) { |
|
| 4781 | + return join( ', ', array_reverse( $caller ) ); |
|
| 4782 | + } else { |
|
| 4783 | + return $caller; |
|
| 4784 | + } |
|
| 4785 | + } |
|
| 4628 | 4786 | |
| 4629 | 4787 | /** |
| 4630 | 4788 | * Retrieve ids that are not already present in the cache. |
@@ -4658,8 +4816,9 @@ discard block |
||
| 4658 | 4816 | * @return bool Whether the device is able to upload files. |
| 4659 | 4817 | */ |
| 4660 | 4818 | function _device_can_upload() { |
| 4661 | - if ( ! wp_is_mobile() ) |
|
| 4662 | - return true; |
|
| 4819 | + if ( ! wp_is_mobile() ) { |
|
| 4820 | + return true; |
|
| 4821 | + } |
|
| 4663 | 4822 | |
| 4664 | 4823 | $ua = $_SERVER['HTTP_USER_AGENT']; |
| 4665 | 4824 | |
@@ -4722,11 +4881,13 @@ discard block |
||
| 4722 | 4881 | * @since 3.6.0 |
| 4723 | 4882 | */ |
| 4724 | 4883 | function wp_auth_check_load() { |
| 4725 | - if ( ! is_admin() && ! is_user_logged_in() ) |
|
| 4726 | - return; |
|
| 4884 | + if ( ! is_admin() && ! is_user_logged_in() ) { |
|
| 4885 | + return; |
|
| 4886 | + } |
|
| 4727 | 4887 | |
| 4728 | - if ( defined( 'IFRAME_REQUEST' ) ) |
|
| 4729 | - return; |
|
| 4888 | + if ( defined( 'IFRAME_REQUEST' ) ) { |
|
| 4889 | + return; |
|
| 4890 | + } |
|
| 4730 | 4891 | |
| 4731 | 4892 | $screen = get_current_screen(); |
| 4732 | 4893 | $hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' ); |
@@ -4831,8 +4992,9 @@ discard block |
||
| 4831 | 4992 | * @return string Tag RegEx. |
| 4832 | 4993 | */ |
| 4833 | 4994 | function get_tag_regex( $tag ) { |
| 4834 | - if ( empty( $tag ) ) |
|
| 4835 | - return; |
|
| 4995 | + if ( empty( $tag ) ) { |
|
| 4996 | + return; |
|
| 4997 | + } |
|
| 4836 | 4998 | return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) ); |
| 4837 | 4999 | } |
| 4838 | 5000 | |
@@ -4850,12 +5012,14 @@ discard block |
||
| 4850 | 5012 | */ |
| 4851 | 5013 | function _canonical_charset( $charset ) { |
| 4852 | 5014 | if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || |
| 4853 | - 'UTF8' === $charset ) |
|
| 4854 | - return 'UTF-8'; |
|
| 5015 | + 'UTF8' === $charset ) { |
|
| 5016 | + return 'UTF-8'; |
|
| 5017 | + } |
|
| 4855 | 5018 | |
| 4856 | 5019 | if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset || |
| 4857 | - 'iso8859-1' === $charset || 'ISO8859-1' === $charset ) |
|
| 4858 | - return 'ISO-8859-1'; |
|
| 5020 | + 'iso8859-1' === $charset || 'ISO8859-1' === $charset ) { |
|
| 5021 | + return 'ISO-8859-1'; |
|
| 5022 | + } |
|
| 4859 | 5023 | |
| 4860 | 5024 | return $charset; |
| 4861 | 5025 | } |
@@ -4890,11 +5054,13 @@ discard block |
||
| 4890 | 5054 | static $encodings = array(); |
| 4891 | 5055 | static $overloaded = null; |
| 4892 | 5056 | |
| 4893 | - if ( is_null( $overloaded ) ) |
|
| 4894 | - $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); |
|
| 5057 | + if ( is_null( $overloaded ) ) { |
|
| 5058 | + $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); |
|
| 5059 | + } |
|
| 4895 | 5060 | |
| 4896 | - if ( false === $overloaded ) |
|
| 4897 | - return; |
|
| 5061 | + if ( false === $overloaded ) { |
|
| 5062 | + return; |
|
| 5063 | + } |
|
| 4898 | 5064 | |
| 4899 | 5065 | if ( ! $reset ) { |
| 4900 | 5066 | $encoding = mb_internal_encoding(); |