Changeset 1725193
- Timestamp:
- 09/05/2017 08:54:00 PM (9 years ago)
- Location:
- exifize-my-dates/trunk
- Files:
-
- 2 edited
-
exifize-my-dates.php (modified) (13 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
exifize-my-dates/trunk/exifize-my-dates.php
r806612 r1725193 4 4 Plugin URI: http://wordpress.org/extend/plugins/exifize-my-dates/ 5 5 Description: Photoblog plugin to change the published dates of a selected post type to the EXIF:capture_date of the Featured or 1st attached image of the post. 6 Version: 1. 16 Version: 1.3 7 7 Author: LBell 8 8 Author URI: http://twitter.com/lbell 9 9 License: GPL2 10 10 11 Copyright 201 2-- Loren Bell11 Copyright 2017 -- Loren Bell 12 12 This program is free software; you can redistribute it and/or modify 13 it under the terms of the GNU General Public License, version 2, as 13 it under the terms of the GNU General Public License, version 2, as 14 14 published by the Free Software Foundation. 15 15 … … 35 35 36 36 function exifize_my_dates() { 37 ?> 37 ?> 38 38 <div class=""> 39 39 <h1>EXIFize My Dates</h1> 40 40 41 41 <?php 42 42 43 43 if(isset($_POST['submit']) && $_POST['ptype'] != 'none') { 44 44 // Check nonce if we are asked to do something... … … 50 50 } 51 51 } 52 52 53 53 $args=array( 54 54 'public' => true, 55 55 //'_builtin' => false 56 ); 56 ); 57 57 $output = 'objects'; 58 58 $operator = 'and'; 59 $post_types = get_post_types($args,$output,$operator); 59 $post_types = get_post_types($args,$output,$operator); 60 60 ?> 61 61 62 62 <p>This tool will attempt to <em>irreversably</em> change the <em>actual</em> post date of Post Type selected below. 63 <br /><small><em>Note: since this changes the actual post date, if you are using dates in your permalink structure, this will change them, possibly breaking incomming links.</small></em></p> 63 <br /><small><em>Note: since this changes the actual post date, if you are using dates in your permalink structure, this will change them, possibly breaking incomming links.</small></em></p> 64 64 </p> 65 65 <p>The date will be changed using (in order of priority):</p> 66 <ol> 66 <ol> 67 67 <li>'exifize_date' custom meta (date or 'skip')**</li> 68 68 <li>EXIF date of Featured Image</li> 69 69 <li>EXIF date of the first attached image</li> 70 <li>Do nothing. Be nothing.</li> 70 <li>Do nothing. Be nothing.</li> 71 71 </ol> 72 72 73 73 <p>Choose the post type who's dates you want to change:</p> 74 74 <form name="input" action="<?php $_SERVER['PHP_SELF'];?>" method="post"> 75 75 <?php 76 if ( function_exists('wp_nonce_field') ) wp_nonce_field('exifize_my_dates_nuclear_nonce'); 76 if ( function_exists('wp_nonce_field') ) wp_nonce_field('exifize_my_dates_nuclear_nonce'); 77 77 ?> 78 78 79 79 <select name="ptype"> 80 80 <option value="none">None</option> 81 81 <?php 82 foreach ($post_types as $post_type ){ 82 foreach ($post_types as $post_type ){ 83 83 if($post_type->name != 'attachment') echo '<option value="'. $post_type->name .'">'. $post_type->label . '</option>'; 84 84 } … … 87 87 <input type="submit" name="submit" value="Submit" /> 88 88 </form> 89 89 90 90 <p><em>**To override the function with a custom date, create a new custom meta field with the name: 'exifize_date' and value: 'YYYY-MM-DD hh:mm:ss' -- for example: '2012-06-23 14:07:00' (no quotes). You can also enter value: 'skip' to prevent the EXIFizer from making any changes.</em></p> 91 91 <br /> … … 102 102 echo "<h2>Working...</h2>"; 103 103 104 $args = array( 104 $args = array( 105 105 'post_type' => $ptype, 106 106 'numberposts' => -1, 107 'post_status' => 'any', 107 'post_status' => 'any', 108 108 ); 109 109 … … 118 118 $metadate = trim(get_post_meta($postid, 'exifize_date', true)); 119 119 $pediturl = get_admin_url() . "post.php?post=" . $postid . "&action=edit"; 120 121 echo "<p>Processing " . $ptype . " <a href = \"". $pediturl . "\" title=\"Edit " . $ptype . " \">" . $postid . ": \"" . $posttitle . "\"</a> "; 122 120 121 echo "<p>Processing " . $ptype . " <a href = \"". $pediturl . "\" title=\"Edit " . $ptype . " \">" . $postid . ": \"" . $posttitle . "\"</a> "; 122 123 123 if($metadate && $metadate != ''){ //If custome meta `efize_date` is set, use it 124 124 switch ($metadate){ … … 135 135 }else{ 136 136 $attachid = get_post_thumbnail_id($postid); // First, try to get the featured image id 137 137 138 138 if($attachid){ 139 139 $exifdetails = "Featured Image"; 140 $attachname = get_post( $attachid )->post_title; 140 $attachname = get_post( $attachid )->post_title; 141 141 }else{ // if no featured image id, then get first attached 142 $attachargs = array( 143 'post_parent' => $postid, 144 'post_type' => 'attachment', 145 'numberposts' => 1, 146 'post_status' => 'any', 142 $attachargs = array( 143 'post_parent' => $postid, 144 'post_type' => 'attachment', 145 'numberposts' => 1, 146 'post_status' => 'any', 147 147 ); 148 148 149 149 $attachment = get_posts($attachargs); 150 150 151 151 if($attachment){ 152 152 $attachid = $attachment[0]->ID; 153 $attachname = $attachment[0]->post_name; 153 $attachname = $attachment[0]->post_name; 154 154 $exifdetails = "attached image"; 155 155 } else { 156 156 $exifdetails = "What are you doing, Dave?"; 157 157 } 158 } // end if no featured image 159 160 161 158 } // end if no featured image 159 160 161 162 162 if(!$attachid){ 163 163 $exifdate = "none"; // No attachment or thumbnail ID found 164 164 } else { 165 echo "using EXIF date from " . $exifdetails . " id ". $attachid . ": \"" . $attachname . "\"</p>"; 166 165 echo "using EXIF date from " . $exifdetails . " id ". $attachid . ": \"" . $attachname . "\"</p>"; 166 167 167 $imgmeta = wp_get_attachment_metadata($attachid, false); 168 169 if($imgmeta && $imgmeta['image_meta']['created_timestamp'] != 0){ //use EXIF date if not 0 170 $exifdate = date("Y-m-d H:i:s", $imgmeta['image_meta']['created_timestamp']); 168 169 if($imgmeta && $imgmeta['image_meta']['created_timestamp'] != 0){ //use EXIF date if not 0 170 $exifdate = date("Y-m-d H:i:s", $imgmeta['image_meta']['created_timestamp']); 171 171 } else { 172 172 $exifdate = 'badexif'; … … 174 174 }// end get EXIF date 175 175 }// end no metadate 176 176 177 177 // if we have image meta and it is not 0 then... 178 178 179 179 switch ($exifdate){ 180 180 case 'skip': … … 182 182 $exifexclass = "updated"; 183 183 break; 184 case 'none': 184 case 'none': 185 185 $exifexcuse = __("SKIP: No attachment, featured image, or 'exifize_date' meta found"); 186 186 $exifexclass = "updated"; … … 193 193 $exifexcuse = __("SKIP: WARNING - 'exifize_date' custom meta is formatted wrong: ") . $metadate; 194 194 $exifexclass = "error"; 195 break; 195 break; 196 196 case $postdate: 197 197 $exifexcuse = __("Already EXIFized!"); … … 205 205 //'edit_date' => true, 206 206 ); 207 207 208 208 $howditgo = wp_update_post($update_post); 209 209 210 210 if($howditgo != 0){ 211 211 $exifexcuse = "Post " . $howditgo . " EXIFIZED! using " . $exifdetails . " date: " . $exifdate . " " ; … … 214 214 $exifexcuse = "ERROR... something went wrong... with " . $postid .". You might get that checked out."; 215 215 $exifexclass = "error highlight"; 216 } //end howditgo 217 } //end switch 218 216 } //end howditgo 217 } //end switch 218 219 219 echo "<div class=\"" . $exifexclass . "\"><p>" . $exifexcuse . "</p></div>"; 220 220 221 221 endforeach; 222 222 223 223 ?> 224 224 <h2>All done!</h2> … … 228 228 <li>EXIF dates are missing</li> 229 229 <li>The stars have mis-aligned creating a reverse vortex, inserting a bug in the program... please let me know and I'll try to fix it.</li> 230 </ol> 231 </p> 232 230 </ol> 231 </p> 232 233 233 <br /><hr><br /> 234 234 <h2>Again?</h2> 235 <?php 235 <?php 236 236 } //end function exifizer_nuclear_option 237 237 ?> -
exifize-my-dates/trunk/readme.txt
r806612 r1725193 2 2 Contributors: Driftless1 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BTMZ87DJDYBPS 4 Tags: EXIF, date, photoblog, custom, post, bulk, 4 Tags: EXIF, date, photoblog, custom, post, bulk, 5 5 Requires at least: 3.0 6 Tested up to: 3.7.17 Stable tag: 1. 16 Tested up to: 4.8.1 7 Stable tag: 1.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 48 48 == Changelog == 49 49 50 = 1.3 = 51 * Tested with WP 4.8 52 50 53 = 1.1 = 51 54 * Added security features to keep others from meddl'n with your affairs … … 53 56 = 1.0 = 54 57 * After a year of safe use on many blogs, I declare this plugin stable! (Or if anyone has had issues, they sure haven't talked to me about it) 55 * Tested to WP 3.7.1 58 * Tested to WP 3.7.1 56 59 * Note - some needed housecleaning might deactivate this plugin upon update. Since it doesn't do anything automatic... Should be no worries. Just re-activate and go on your merry way. 57 60 58 61 = 0.1 = 59 62 First release 60 61
Note: See TracChangeset
for help on using the changeset viewer.