Changeset 1216 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php
- Timestamp:
- 02/03/2015 11:33:49 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php
r1150 r1216 97 97 // First things first. Do we have something to work with? 98 98 if ( empty( $theme_files ) ) { 99 $this->remove_files( $this->tmp_dir );100 101 99 return __( 'The zip file was empty.', 'wporg-themes' ); 102 100 } … … 105 103 $style_css = $this->get_style_css( $theme_files ); 106 104 if ( empty( $style_css ) ) { 107 $this->remove_files( $this->tmp_dir );108 109 105 return sprintf( __( 'The zip file must include a file named %s.', 'wporg-themes' ), '<code>style.css</code>' ); 110 106 } … … 117 113 // We need a screen shot. People love screen shots. 118 114 if ( ! $this->has_screen_shot( $theme_files ) ) { 119 $this->remove_files( $this->tmp_dir );120 121 115 return sprintf( __( 'The zip file must include a file named %1$s or %2$s.', 'wporg-themes' ), '<code>screenshot.png</code>', '<code>screenshot.jpg</code>' ); 122 116 } … … 125 119 126 120 if ( ! $this->theme->get( 'Name' ) ) { 127 $this->remove_files( $this->tmp_dir );128 129 121 return __( "The theme has no name. Add it to style.css and upload the theme again. <a href='http://codex.wordpress.org/Theme_Development#Theme_Style_Sheet'>Theme Style Sheets</a>", 'wporg-themes' ); 130 122 } … … 132 124 $theme_description = $this->strip_non_utf8( (string) $this->theme->get( 'Description' ) ); 133 125 if ( empty( $theme_description ) ) { 134 $this->remove_files( $this->tmp_dir );135 136 126 return sprintf( __( 'The theme has no description. Add it to <code>style.css</code> and upload the theme again. <a href="%s">Theme Style Sheets</a>', 'wporg-themes' ), 'http://codex.wordpress.org/Theme_Development#Theme_Style_Sheet' ); 137 127 } 138 128 139 129 if ( ! $this->theme->get( 'Tags' ) ) { 140 $this->remove_files( $this->tmp_dir );141 142 130 return __( 'The stylesheet has no tags. Add a Tags: line to your <code>style.css</code> file and upload the zip file again.', 'wporg-themes' ); 143 131 } 144 132 145 133 if ( ! $this->theme->get( 'Version' ) ) { 146 $this->remove_files( $this->tmp_dir );147 148 134 return __( 'The stylesheet has no version. Add a Version: line to your <code>style.css</code> file and upload the zip file again.', 'wporg-themes' ); 149 135 } 150 136 151 137 if ( preg_match( '|[^\d\.]|', $this->theme->get( 'Version' ) ) ) { 152 $this->remove_files( $this->tmp_dir );153 154 138 return __( 'Version strings can only contain numeric and period characters (like 1.2). Please fix your Version: line in <code>style.css</code> and upload your theme again.', 'wporg-themes' ); 155 139 } … … 157 141 // Make sure we have version that is higher than any previously uploaded version of this theme. 158 142 if ( ! empty( $this->theme_post ) && ! version_compare( $this->theme->get( 'Version' ), $this->theme_post->max_version, '>' ) ) { 159 $this->remove_files( $this->tmp_dir );160 161 143 return sprintf( __( 'You need to upload a version of %1$s higher than %2$s. Increase the theme version number in <code>style.css</code>, then upload your zip file again.', 'wporg-themes' ), $this->theme->display( 'Name' ), '<code>' . $this->theme->display( 'Version' ) . '</code>' ); 162 144 } … … 164 146 // Prevent duplicate URLs. 165 147 if ( ! $this->theme->get( 'ThemeURI' ) && ! $this->theme->get( 'AuthorURI' ) && $this->theme->get( 'ThemeURI' ) == $this->theme->get( 'AuthorURI' ) ) { 166 $this->remove_files( $this->tmp_dir );167 168 148 return __( 'Duplicate theme and author URLs. A theme URL is a page/site the provides details about this specific theme. An author URL is a page/site that provides information about the author of the theme. You aren’t required to provide both, so pick the one that best applies to your URL.', 'wporg-themes' ); 169 149 } … … 171 151 // Check for child theme's parent in the directory (non-buddypress only) 172 152 if ( $this->theme->parent() && ! in_array( 'buddypress', $this->theme->get( 'Tags' ) ) && ! $this->is_parent_available() ) { 173 $this->remove_files( $this->tmp_dir );174 175 153 return sprintf( __( 'There is no theme called %s in the directory. For child themes, you must use a parent theme that already exists in the directory.', 'wporg-themes' ), '<code>' . $this->theme->parent() . '</code>' ); 176 154 } … … 178 156 // Make sure it doesn't use a slug deemed not to be used by the public. 179 157 if ( $this->has_reserved_slug() ) { 180 $this->remove_files( $this->tmp_dir );181 182 158 return sprintf( __( 'Sorry, the theme name %s is reserved for use by WordPress Core. Please change the name of your theme in <code>style.css</code> and upload it again.', 'wporg-themes' ), '<code>' . $this->theme->get_stylesheet() . '</code>' ); 183 159 } … … 185 161 // Is there already a theme with the name name by a different author? 186 162 if ( ! empty( $this->theme_post ) && $this->theme_post->post_author != $this->author->ID ) { 187 $this->remove_files( $this->tmp_dir );188 189 163 return sprintf( __( 'There is already a theme called %s by a different author. Please change the name of your theme in <code>style.css</code> and upload it again.', 'wporg-themes' ), '<code>' . $this->theme->get_stylesheet() . '</code>' ); 190 164 } … … 192 166 // We know it's the correct author, now we can check if it's suspended. 193 167 if ( ! empty( $this->theme_post ) && 'trash' === $this->theme_post->post_status ) { 194 $this->remove_files( $this->tmp_dir );195 196 168 return sprintf( __( 'This theme is suspended from the Theme Repository and it can’t be updated. If you have any questions about this please contact %s.', 'wporg-themes' ), '<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>' ); 197 169 } … … 203 175 204 176 if ( ! $result ) { 205 $this->remove_files( $this->tmp_dir );206 207 177 return sprintf( __( 'Your theme has failed the theme check. Please correct the problems with it and upload it again. You can also use the <a href="%1$s">Theme Check Plugin</a> to test your theme before uploading. If you have any questions about this please contact %2$s.', 'wporg-themes' ), '//wordpress.org/plugins/theme-check/', '<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>' ); 208 178 } … … 219 189 220 190 if ( ! $ticket_id ) { 221 $this->remove_files( $this->tmp_dir );222 223 191 return sprintf( __( 'There was an error creating a Trac ticket for your theme, please report this error to %s', 'wporg-themes' ), '<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a>' ); 224 192 } … … 232 200 // Send theme author an email for peace of mind. 233 201 $this->send_email_notification( $ticket_id ); 234 235 // Finally remove all temporary files.236 $this->remove_files( $this->tmp_dir );237 202 238 203 do_action( 'theme_upload', $this->theme ); … … 265 230 $this->theme_dir = "{$this->tmp_dir}/{$base_name}"; 266 231 mkdir( $this->theme_dir, 0777 ); 232 233 // Make sure we clean up after ourselves. 234 add_action( 'shutdown', array( $this, 'remove_files' ) ); 267 235 } 268 236 … … 694 662 695 663 /** 696 * Deletes the passed files or directory. 697 * 698 * @param string $files 699 */ 700 public function remove_files( $files ) { 664 * Deletes the temporary directory. 665 */ 666 public function remove_files() { 701 667 $rm = escapeshellarg( self::RM ); 702 $files = escapeshellarg( $ files);668 $files = escapeshellarg( $this->tmp_dir ); 703 669 704 670 exec( escapeshellcmd( "{$rm} -rf {$files}" ) );
Note: See TracChangeset
for help on using the changeset viewer.