Plugin Directory

Changeset 1725193


Ignore:
Timestamp:
09/05/2017 08:54:00 PM (9 years ago)
Author:
Driftless1
Message:

tested

Location:
exifize-my-dates/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • exifize-my-dates/trunk/exifize-my-dates.php

    r806612 r1725193  
    44Plugin URI: http://wordpress.org/extend/plugins/exifize-my-dates/
    55Description: 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.1
     6Version: 1.3
    77Author: LBell
    88Author URI: http://twitter.com/lbell
    99License: GPL2
    1010
    11     Copyright 2012 -- Loren Bell
     11    Copyright 2017 -- Loren Bell
    1212    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
    1414    published by the Free Software Foundation.
    1515
     
    3535
    3636function exifize_my_dates() {
    37     ?> 
     37    ?>
    3838    <div class="">
    3939        <h1>EXIFize My Dates</h1>
    40        
     40
    4141    <?php
    42    
     42
    4343    if(isset($_POST['submit']) && $_POST['ptype'] != 'none') {
    4444        // Check nonce if we are asked to do something...
     
    5050        }
    5151    }
    52    
     52
    5353    $args=array(
    5454        'public'   => true,
    5555        //'_builtin' => false
    56     ); 
     56    );
    5757    $output = 'objects';
    5858    $operator = 'and';
    59     $post_types = get_post_types($args,$output,$operator); 
     59    $post_types = get_post_types($args,$output,$operator);
    6060    ?>
    61    
     61
    6262        <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>
    6464        </p>
    6565        <p>The date will be changed using (in order of priority):</p>
    66         <ol> 
     66        <ol>
    6767            <li>'exifize_date' custom meta (date or 'skip')**</li>
    6868            <li>EXIF date of Featured Image</li>
    6969            <li>EXIF date of the first attached image</li>
    70             <li>Do nothing. Be nothing.</li>       
     70            <li>Do nothing. Be nothing.</li>
    7171        </ol>
    72        
     72
    7373        <p>Choose the post type who's dates you want to change:</p>
    7474        <form name="input" action="<?php $_SERVER['PHP_SELF'];?>" method="post">
    7575            <?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');
    7777            ?>
    78            
     78
    7979            <select name="ptype">
    8080                <option value="none">None</option>
    8181                <?php
    82                     foreach ($post_types  as $post_type ){ 
     82                    foreach ($post_types  as $post_type ){
    8383                        if($post_type->name != 'attachment') echo '<option value="'. $post_type->name .'">'. $post_type->label . '</option>';
    8484                    }
     
    8787            <input type="submit"  name="submit" value="Submit" />
    8888        </form>
    89            
     89
    9090        <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>
    9191        <br />
     
    102102    echo "<h2>Working...</h2>";
    103103
    104     $args = array( 
     104    $args = array(
    105105        'post_type' => $ptype,
    106106        'numberposts' => -1,
    107         'post_status' => 'any', 
     107        'post_status' => 'any',
    108108    );
    109109
     
    118118        $metadate = trim(get_post_meta($postid, 'exifize_date', true));
    119119        $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
    123123        if($metadate && $metadate != ''){                               //If custome meta `efize_date` is set, use it
    124124            switch ($metadate){
     
    135135        }else{
    136136            $attachid = get_post_thumbnail_id($postid); // First, try to get the featured image id
    137            
     137
    138138            if($attachid){
    139139                $exifdetails = "Featured Image";
    140                 $attachname = get_post( $attachid )->post_title;   
     140                $attachname = get_post( $attachid )->post_title;
    141141            }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',
    147147                );
    148148
    149149                $attachment = get_posts($attachargs);
    150            
     150
    151151                if($attachment){
    152152                    $attachid = $attachment[0]->ID;
    153                     $attachname = $attachment[0]->post_name; 
     153                    $attachname = $attachment[0]->post_name;
    154154                    $exifdetails = "attached image";
    155155                } else {
    156156                    $exifdetails = "What are you doing, Dave?";
    157157                }
    158             } // end if no featured image 
    159 
    160            
    161        
     158            } // end if no featured image
     159
     160
     161
    162162            if(!$attachid){
    163163                $exifdate = "none";  // No attachment or thumbnail ID found
    164164            } 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
    167167                $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']);
    171171                } else {
    172172                    $exifdate = 'badexif';
     
    174174            }// end get EXIF date
    175175        }// end no metadate
    176        
     176
    177177        // if we have image meta and it is not 0 then...
    178        
     178
    179179        switch ($exifdate){
    180180        case 'skip':
     
    182182            $exifexclass = "updated";
    183183            break;
    184         case 'none':   
     184        case 'none':
    185185            $exifexcuse = __("SKIP: No attachment, featured image, or 'exifize_date' meta found");
    186186            $exifexclass = "updated";
     
    193193            $exifexcuse = __("SKIP: WARNING - 'exifize_date' custom meta is formatted wrong: ") . $metadate;
    194194            $exifexclass = "error";
    195             break;     
     195            break;
    196196        case $postdate:
    197197            $exifexcuse = __("Already EXIFized!");
     
    205205                //'edit_date' => true,
    206206            );
    207    
     207
    208208            $howditgo = wp_update_post($update_post);
    209    
     209
    210210            if($howditgo != 0){
    211211                $exifexcuse = "Post " . $howditgo . " EXIFIZED! using " . $exifdetails . " date: " . $exifdate . " " ;
     
    214214                $exifexcuse = "ERROR... something went wrong... with " . $postid .". You might get that checked out.";
    215215                $exifexclass = "error highlight";
    216             } //end howditgo               
    217         } //end switch 
    218        
     216            } //end howditgo
     217        } //end switch
     218
    219219        echo "<div class=\"" . $exifexclass . "\"><p>" . $exifexcuse . "</p></div>";
    220        
     220
    221221    endforeach;
    222    
     222
    223223    ?>
    224224    <h2>All done!</h2>
     
    228228        <li>EXIF dates are missing</li>
    229229        <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
    233233    <br /><hr><br />
    234234    <h2>Again?</h2>
    235     <?php 
     235    <?php
    236236} //end function exifizer_nuclear_option
    237237?>
  • exifize-my-dates/trunk/readme.txt

    r806612 r1725193  
    22Contributors: Driftless1
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BTMZ87DJDYBPS
    4 Tags: EXIF, date, photoblog, custom, post, bulk, 
     4Tags: EXIF, date, photoblog, custom, post, bulk,
    55Requires at least: 3.0
    6 Tested up to: 3.7.1
    7 Stable tag: 1.1
     6Tested up to: 4.8.1
     7Stable tag: 1.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4848== Changelog ==
    4949
     50= 1.3 =
     51* Tested with WP 4.8
     52
    5053= 1.1 =
    5154* Added security features to keep others from meddl'n with your affairs
     
    5356= 1.0 =
    5457* 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
    5659* 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.
    5760
    5861= 0.1 =
    5962First release
    60 
    61 
Note: See TracChangeset for help on using the changeset viewer.