Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -crB orig/format-media-titles.php new/format-media-titles.php
- *** orig/format-media-titles.php 2011-10-24 12:00:00.000000000 -0700
- --- new/format-media-titles.php 2012-10-13 17:07:20.000000000 -0700
- ***************
- *** 91,96 ****
- --- 91,98 ----
- <label><input name="fmt_options[chk_tilde]" type="checkbox" value="1" <?php if (isset($options['chk_tilde'])) { checked('1', $options['chk_tilde']); } ?> /> Tilde (~)</label><br />
- <label><input name="fmt_options[chk_plus]" type="checkbox" value="1" <?php if (isset($options['chk_plus'])) { checked('1', $options['chk_plus']); } ?> /> Plus (+)</label>
- + <br />
- + <label><input name="fmt_options[chk_digits]" type="checkbox" value="1" <?php if (isset($options['chk_digits'])) { checked('1', $options['chk_digits']); } ?> /> Remove digits (0 - 9) excluding DCF camera names</label><br />
- </td>
- </tr>
- ***************
- *** 163,168 ****
- --- 165,183 ----
- $uploaded_post_id = get_post( $id );
- $title = $uploaded_post_id->post_title;
- + /* remove trailing numbers if less than 4 digits so will keep DCF file names (camera formatted names) */
- + if( isset($options['chk_digits']) && $options['chk_digits'] ) {
- + if (is_numeric(substr($title, -4))) {
- + unset($options['chk_underscore']);
- + unset($options['chk_hyphen']);
- + if (substr($title,0, 1) == '_') $title = substr($title, 1); // WP removes leading '_' from filename. This is so DCF title matchs
- + }
- + else {
- + // remove any digits 0 - 9
- + $title = preg_replace("/\d+/", "", $title);
- + }
- + }
- +
- /* Update post. */
- $char_array = array();
- if( isset($options['chk_hyphen']) && $options['chk_hyphen'] ) $char_array[] = '-';
- ***************
- *** 200,206 ****
- // Update the post into the database
- $uploaded_post = array();
- $uploaded_post['ID'] = $id;
- ! $uploaded_post['post_title'] = $title;
- wp_update_post( $uploaded_post );
- }
- ! add_action( 'add_attachment', 'fmt_update_media_title' );
- \ No newline at end of file
- --- 215,221 ----
- // Update the post into the database
- $uploaded_post = array();
- $uploaded_post['ID'] = $id;
- ! $uploaded_post['post_title'] = trim($title);
- wp_update_post( $uploaded_post );
- }
- ! add_action( 'add_attachment', 'fmt_update_media_title' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement