Plugin Directory

Changeset 1208950


Ignore:
Timestamp:
07/29/2015 11:52:47 AM (11 years ago)
Author:
phuisman
Message:

small bugfix 1.0.6

Location:
flickr-field-for-advanced-custom-fields/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v4.php

    r1110271 r1208950  
    22
    33class acf_field_flickr extends acf_field {
    4    
     4
    55    // vars
    66    var $settings, // will hold info such as dir / path
    77        $defaults; // will hold default field options
    8        
    9        
     8
     9
    1010    /*
    1111    *  __construct
     
    1616    *  @date    23/01/13
    1717    */
    18    
     18
    1919    function __construct()
    2020    {
     
    2424        $this->category = __("Content", 'acf'); // Basic, Content, Choice, etc
    2525        $this->defaults = array(
    26             // add default here to merge into your field. 
     26            // add default here to merge into your field.
    2727            'flickr_api_key'        => '',
    2828            'flickr_user_id'        => '',
     
    3535            'flickr_cache_duration' => '168',
    3636        );
    37        
    38        
     37
     38
    3939        // do not delete!
    4040    parent::__construct();
    41        
    42        
     41
     42
    4343    // settings
    4444        $this->settings = array(
     
    4949
    5050    }
    51    
    52    
     51
     52
    5353    /*
    5454    *  create_options()
     
    6363    *  @param   $field  - an array holding all the field's data
    6464    */
    65    
     65
    6666    function create_options( $field ) {
    6767        // defaults?
     
    6969        $field = array_merge($this->defaults, $field);
    7070        */
    71        
     71
    7272        // key is needed in the field names to correctly save the data
    73         $key = $field['name'];     
    74        
     73        $key = $field['name'];
     74
    7575        // Create Fields
    76         ?> 
     76        ?>
    7777        <tr class="field_option field_option_<?php echo $this->name; ?>">
    7878            <td class="label">
     
    8181            </td>
    8282            <td>
    83                 <?php       
     83                <?php
    8484                do_action('acf/create_field', array(
    8585                    'type'      =>  'text',
    8686                    'name'      =>  'fields['.$key.'][flickr_user_id]',
    8787                    'value'     =>  $field['flickr_user_id'],
    88                 ));     
     88                ));
    8989                ?>
    9090            </td>
     
    9696            </td>
    9797            <td>
    98                 <?php       
     98                <?php
    9999                do_action('acf/create_field', array(
    100100                    'type'      =>  'text',
    101101                    'name'      =>  'fields['.$key.'][flickr_api_key]',
    102102                    'value'     =>  $field['flickr_api_key'],
    103                 ));     
    104                 ?>
    105             </td>
    106         </tr>   
     103                ));
     104                ?>
     105            </td>
     106        </tr>
    107107        <tr class="field_option field_option_<?php echo $this->name; ?>">
    108108            <td class="label">
     
    148148                ?>
    149149           </td>
    150         </tr>       
     150        </tr>
    151151        <tr class="field_option field_option_<?php echo $this->name; ?>">
    152152            <td class="label">
     
    168168                <label><?php _e( 'Enable cache', 'acf-flickr' );?></label>
    169169                <p class="description">
    170                     <?php 
     170                    <?php
    171171                    $cache_dir = dirname(__FILE__) . '/cache';
    172                     if (!   is_writeable($cache_dir)) {         
     172                    if (!   is_writeable($cache_dir)) {
    173173                        echo __('The cache folder <em>'. $cache_dir . '</em> is <span style="color:#CC0000; font-weight:bold">not writable</span>. Make sure cache can be used by executing <i>sudo chmod 777</i> on the cache folder.', 'acf-flickr');
    174174                    }
     
    199199            </td>
    200200            <td>
    201                 <?php       
     201                <?php
    202202                do_action('acf/create_field', array(
    203203                    'type'      =>  'text',
    204204                    'name'      =>  'fields['.$key.'][flickr_cache_duration]',
    205205                    'value'     =>  $field['flickr_cache_duration'],
    206                 ));     
     206                ));
    207207                ?>
    208208            </td>
     
    255255        </tr>
    256256        <?php
    257        
     257
    258258    }
    259    
    260    
     259
     260
    261261    /*
    262262    *  create_field()
     
    270270    *  @date    23/01/13
    271271    */
    272    
     272
    273273    function create_field( $field ) {
    274274        // Defaults
    275275        $field['value'] = isset($field['value']) ? $field['value'] : array();
    276276        $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false;
    277        
     277
    278278        // Get all Flickr sets by the given user ID and api key (both required)
    279279        require_once(dirname(__FILE__) . '/phpFlickr.php');
    280280        $f = new phpFlickr($field['flickr_api_key']);
    281        
     281
    282282        // Caching
    283283        $cache_dir = dirname(__FILE__) . '/cache';
    284284        if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) {
    285285            $duration = $field['flickr_cache_duration'] * 60 * 60;
    286             $f->enableCache('fs', $cache_dir, $duration);       
    287         }       
    288        
     286            $f->enableCache('fs', $cache_dir, $duration);
     287        }
     288
    289289        $field['choices'] = array();
    290290        $field['choices'][''] = '';
    291291        ?>
    292        
     292
    293293        <div class="field_form flickr_field type_<?php echo $field['flickr_content_type']; ?>">
    294294            <?php
    295295            $items = array();
    296             $items = json_decode($field['value']['items']);
     296
     297            if (isset($field['value']['items'])) {
     298                $items = json_decode($field['value']['items']);
     299            }
    297300
    298301            // Check for three types of Flickr content; Sets, Galleries and Photostream
     
    300303                if ($field['flickr_content_type'] == 'sets') {
    301304                    $flickr_data = $f->photosets_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1);
    302                 } 
     305                }
    303306                elseif ($field['flickr_content_type'] == 'galleries') {
    304307                    $flickr_data = $f->galleries_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1);
     
    308311                <table class="acf_input widefat acf_field_form_table">
    309312                    <tbody>
    310                         <?php                   
     313                        <?php
    311314                        if (is_array($flickr_data) && !empty($flickr_data)) {
    312315                            if ($field['flickr_content_type'] == 'sets') {
    313316                                $data = $flickr_data['photoset'];
    314                             } 
     317                            }
    315318                            elseif ($field['flickr_content_type'] == 'galleries') {
    316319                                $data = $flickr_data['galleries']['gallery'];
     
    331334                                        <p class="meta_data">
    332335                                            <?php _e('Added on');?> <?php echo date_i18n(get_option('date_format') ,$flickr['date_create']); echo ' &nbsp;|&nbsp; ';
    333                                             echo $flickr['count_views'];?> <?php _e('views on Flickr'); 
     336                                            echo $flickr['count_views'];?> <?php _e('views on Flickr');
    334337                                            echo ' &nbsp;|&nbsp; ';
    335338                                            echo $flickr['photos'];?> <?php _e('Photos');
     
    343346                                <?php
    344347                            }
    345                         }   
     348                        }
    346349                        else {
    347350                            ?><tr class="field_label">
    348351                                <td colspan="2"><?php _e('There are no Flickr sets available for user ID'); ?> <?php echo $field['flickr_user_id']; ?> <?php _e('or there is a problem with API KEY'); ?> <?php echo $field['api_key']; ?></td>
    349352                            </tr><?php
    350                         }       
     353                        }
    351354                    ?>
    352355                </tbody>
     
    356359            elseif($field['flickr_content_type'] == 'photostream') {
    357360                $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], '');
    358            
     361
    359362                if (is_array($flickr_data['photos']) && isset($flickr_data['photos']['photo'][0])):  ?>
    360363                    <ul class="field_label photostream">
    361364                        <?php foreach($flickr_data['photos']['photo'] as $key => $photo): ?>
    362                             <?php 
     365                            <?php
    363366                            $active = '';
    364367                            if (is_array($items)) {
     
    371374                            }
    372375                            ?>
    373                             <li class="label flickr_row photo_image<?php echo $active; ?>" 
    374                                 data-flickr-id="<?php echo $photo['id']; ?>" 
     376                            <li class="label flickr_row photo_image<?php echo $active; ?>"
     377                                data-flickr-id="<?php echo $photo['id']; ?>"
    375378                                data-flickr-server="<?php echo $photo['server']; ?>"
    376379                                data-flickr-secret="<?php echo $photo['secret']; ?>"
     
    385388                <?php else: ?>
    386389                    <p><?php _e('There are no Flickr sets available for user ID'); ?> <?php echo $field['flickr_user_id']; ?> <?php _e('or there is a problem with API KEY'); ?> <?php echo $field['api_key']; ?></p>
    387                 <?php 
     390                <?php
    388391                endif;
    389             }   
     392            }
    390393            ?>
    391394        </div>
    392        
    393         <?php 
     395
     396        <?php
    394397        if (!empty($sets['photoset'])) {
    395398            foreach($sets['photoset'] as $set_key => $set) {
     
    398401            }
    399402        }
    400            
     403
    401404        // no choices
    402405        if(empty($field['choices']))
     
    405408            return false;
    406409        }
    407        
     410
    408411        // html
    409412        if (!isset($multiple)) { $multiple = ''; }
    410         echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' data-max-selectable="'. $field['flickr_max_selected'] .'" data-flickr-type="'. $field['flickr_content_type'] .'">';   
    411        
     413        echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . ' data-max-selectable="'. $field['flickr_max_selected'] .'" data-flickr-type="'. $field['flickr_content_type'] .'">';
     414
    412415        // null
    413416        if($field['required'] == '1')
     
    415418            echo '<option value="null"> - Select - </option>';
    416419        }
    417        
     420
    418421        // loop through values and add them as options
    419422        foreach($field['choices'] as $key => $value)
     
    423426                // this select is grouped with optgroup
    424427                if($key != '') echo '<optgroup label="'.$key.'">';
    425                
     428
    426429                if($value)
    427430                {
     
    441444                                $selected = 'selected="selected"';
    442445                            }
    443                         }   
     446                        }
    444447                        echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>';
    445448                    }
    446449                }
    447                
     450
    448451                if($key != '') echo '</optgroup>';
    449452            }
     
    463466                        $selected = 'selected="selected"';
    464467                    }
    465                 }   
     468                }
    466469                echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
    467470            }
    468            
     471
    469472        }
    470473
    471474        echo '</select>';
    472        
     475
    473476    }
    474    
    475    
     477
     478
    476479    /*
    477480    *  input_admin_enqueue_scripts()
     
    490493        // register ACF scripts
    491494        wp_register_script( 'acf-flickr-init', $this->settings['dir'] . 'js/flickr-acf4.js', array('acf-input'), $this->settings['version'] );
    492         wp_register_style( 'acf-input-flickr', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version'] ); 
    493        
     495        wp_register_style( 'acf-input-flickr', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version'] );
     496
    494497        // scripts
    495498        wp_enqueue_script(array(
    496             'acf-flickr-init', 
     499            'acf-flickr-init',
    497500        ));
    498501
    499502        // styles
    500503        wp_enqueue_style(array(
    501             'acf-input-flickr', 
     504            'acf-input-flickr',
    502505        ));
    503        
    504        
     506
     507
    505508    }
    506    
    507    
     509
     510
    508511    /*
    509512    *  field_group_admin_enqueue_scripts()
     
    533536    *  @return  $value - the value to be saved in the database
    534537    */
    535    
     538
    536539    function load_value( $value, $post_id, $field )
    537540    {
     
    547550        return $data;
    548551    }
    549    
     552
    550553    /*
    551554    *  format_value_for_api()
     
    563566    *  @return  $value  - the modified value
    564567    */
    565    
     568
    566569    function format_value_for_api( $value, $post_id, $field )
    567570    {
    568571        if (!empty($value['items'])) {
    569             // Decode JSON format that is used in the database 
     572            // Decode JSON format that is used in the database
    570573            $value['items'] = json_decode($value['items']);
    571574
     
    573576            require_once(dirname(__FILE__) . '/phpFlickr.php');
    574577            $f = new phpFlickr($value['api_key']);
    575            
     578
    576579            // enable phpFlickr caching if possible
    577580            $cache_dir = dirname(__FILE__) . '/cache';
    578581            if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) {
    579582                $duration = $field['flickr_cache_duration'] * 60;
    580                 $f->enableCache('fs', $cache_dir, $duration);       
    581             }   
     583                $f->enableCache('fs', $cache_dir, $duration);
     584            }
    582585
    583586            if ($value['type'] == 'sets' || $value['type'] == 'galleries') {
     
    588591                        $photos = $f->photosets_getPhotos($id, 'url_o');
    589592                        $name = 'photoset';
    590                     } 
     593                    }
    591594                    elseif ($value['type'] == 'galleries') {
    592595                        $photos = $f->galleries_getPhotos($id, 'url_o');
     
    599602                        $sets[$id][$photo['id']]['large']    = ($value['large_size'] == 'original') ? $photo['url_o'] : $f->buildPhotoURL($photo, $value['large_size']);
    600603                        $sets[$id][$photo['id']]['photo_id'] = $photo['id'];
    601                     }   
     604                    }
    602605                }
    603606                $value['items'] = $sets;
     
    605608            elseif($value['type'] == 'photostream') {
    606609                $items = array();
    607                
    608                 foreach($value['items'] as $photo) {               
     610
     611                foreach($value['items'] as $photo) {
    609612                    $items[] = array(
    610613                        'title'    => $photo->title,
     
    617620            }
    618621        }
    619        
     622
    620623        return $value;
    621624    }
    622625
    623    
     626
    624627}
    625628
  • flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v5.php

    r1110271 r1208950  
    22
    33class acf_field_flickr extends acf_field {
    4    
     4
    55    /*
    66    *  __construct
     
    1515    *  @return  n/a
    1616    */
    17    
     17
    1818    function __construct() {
    19        
     19
    2020        /*
    2121        *  name (string) Single word, no spaces. Underscores allowed
    2222        */
    23        
     23
    2424        $this->name = 'flickr';
    25        
    26        
     25
     26
    2727        /*
    2828        *  label (string) Multiple words, can include spaces, visible when selecting a field type
    2929        */
    30        
     30
    3131        $this->label = __('Flickr Field', 'flickr');
    32        
    33        
     32
     33
    3434        /*
    3535        *  category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME
    3636        */
    37        
     37
    3838        $this->category = 'content';
    39        
    40        
     39
     40
    4141        /*
    4242        *  defaults (array) Array of default settings which are merged into the field object. These are used later in settings
    4343        */
    44        
     44
    4545        $this->defaults = array(
    4646            'flickr_api_key'        => '',
     
    5454            'flickr_cache_duration' => '168',
    5555        );
    56        
    57                
     56
     57
    5858        // do not delete!
    5959    parent::__construct();
    60        
    61     }
    62    
    63    
     60
     61    }
     62
     63
    6464    /*
    6565    *  render_field_options()
     
    7575    *  @return  n/a
    7676    */
    77    
     77
    7878    function render_field_settings( $field ) {
    7979        acf_render_field_setting( $field, array(
     
    9191            'type'          => 'text',
    9292            'name'          => 'flickr_api_key',
    93         )); 
     93        ));
    9494
    9595        acf_render_field_setting( $field, array(
     
    104104            ),
    105105        ));
    106        
     106
    107107        acf_render_field_setting( $field, array(
    108108            'label'        => __('Display amount','acf-flickr'),
     
    135135            $instructions = '<span style="color:#336600">' . __('The cache folder is writable!', 'acf-flickr') . '</span>';
    136136        }
    137                
     137
    138138        acf_render_field_setting( $field, array(
    139139            'label'        => __('Enable cache','acf-flickr'),
     
    153153            'name'         => 'flickr_cache_duration',
    154154            'append'       => 'minutes',
    155         )); 
     155        ));
    156156
    157157        acf_render_field_setting( $field, array(
     
    163163                'square'     => '75x75 (square)',
    164164                'thumbnail'  => '100px (rectangle)',
    165                 'square_150' => '150x150 (square)',             
     165                'square_150' => '150x150 (square)',
    166166                'small_240'  => '240px (rectangle)',
    167167                'small_320'  => '320px (rectangle)',
    168168            ),
    169169        ));
    170        
     170
    171171        acf_render_field_setting( $field, array(
    172172            'label'        => __('Large size','acf-flickr'),
     
    182182            ),
    183183        ));
    184        
    185        
    186 
    187     }
    188    
    189    
    190    
     184
     185
     186
     187    }
     188
     189
     190
    191191    /*
    192192    *  render_field()
     
    203203    *  @return  n/a
    204204    */
    205    
     205
    206206    function render_field( $field ) {
    207207        // Defaults
    208208        $field['value'] = isset($field['value']) ? $field['value'] : array();
    209209        $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false;
    210        
     210
    211211        // Get all Flickr sets by the given user ID and api key (both required)
    212212        require_once(dirname(__FILE__) . '/phpFlickr.php');
    213213        $f = new phpFlickr($field['flickr_api_key']);
    214        
     214
    215215        // Caching
    216216        $cache_dir = dirname(__FILE__) . '/cache';
    217217        if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) {
    218218            $duration = $field['flickr_cache_duration'] * 60 * 60;
    219             $f->enableCache('fs', $cache_dir, $duration);       
    220         }       
    221        
     219            $f->enableCache('fs', $cache_dir, $duration);
     220        }
     221
    222222        $field['choices'] = array();
    223223        $field['choices'][''] = '';
    224224        ?>
    225        
     225
    226226        <div class="field_form flickr_field type_<?php echo $field['flickr_content_type']; ?>">
    227227            <?php
    228228            $items = array();
    229             $items = json_decode($field['value']['items']);
     229
     230            if (isset($field['value']['items'])) {
     231                $items = json_decode($field['value']['items']);
     232            }
    230233
    231234            // Check for three types of Flickr content; Sets, Galleries and Photostream
     
    233236                if ($field['flickr_content_type'] == 'sets') {
    234237                    $flickr_data = $f->photosets_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1);
    235                 } 
     238                }
    236239                elseif ($field['flickr_content_type'] == 'galleries') {
    237240                    $flickr_data = $f->galleries_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1);
     
    241244                <table class="acf_input widefat acf_field_form_table">
    242245                    <tbody>
    243                         <?php                   
     246                        <?php
    244247                        if (is_array($flickr_data) && !empty($flickr_data)) {
    245248                            if ($field['flickr_content_type'] == 'sets') {
    246249                                $data = $flickr_data['photoset'];
    247                             } 
     250                            }
    248251                            elseif ($field['flickr_content_type'] == 'galleries') {
    249252                                $data = $flickr_data['galleries']['gallery'];
     
    264267                                        <p class="meta_data">
    265268                                            <?php _e('Added on');?> <?php echo date_i18n(get_option('date_format') ,$flickr['date_create']); echo ' &nbsp;|&nbsp; ';
    266                                             echo $flickr['count_views'];?> <?php _e('views on Flickr'); 
     269                                            echo $flickr['count_views'];?> <?php _e('views on Flickr');
    267270                                            echo ' &nbsp;|&nbsp; ';
    268271                                            echo $flickr['photos'];?> <?php _e('Photos');
     
    276279                                <?php
    277280                            }
    278                         }   
     281                        }
    279282                        else {
    280283                            ?><tr class="field_label">
    281284                                <td colspan="2"><?php _e('There are no Flickr sets available for user ID'); ?> <?php echo $field['flickr_user_id']; ?> <?php _e('or there is a problem with API KEY'); ?> <?php echo $field['api_key']; ?></td>
    282285                            </tr><?php
    283                         }       
     286                        }
    284287                    ?>
    285288                </tbody>
     
    292295                    <ul class="field_label photostream">
    293296                        <?php foreach($flickr_data['photos']['photo'] as $key => $photo): ?>
    294                             <?php 
     297                            <?php
    295298                            $active = '';
    296299                            if (is_array($items)) {
     
    303306                            }
    304307                            ?>
    305                             <li class="label flickr_row photo_image<?php echo $active; ?>" 
    306                                 data-flickr-id="<?php echo $photo['id']; ?>" 
     308                            <li class="label flickr_row photo_image<?php echo $active; ?>"
     309                                data-flickr-id="<?php echo $photo['id']; ?>"
    307310                                data-flickr-server="<?php echo $photo['server']; ?>"
    308311                                data-flickr-secret="<?php echo $photo['secret']; ?>"
     
    317320                <?php else: ?>
    318321                    <p><?php _e('There are no Flickr sets available for user ID'); ?> <?php echo $field['flickr_user_id']; ?> <?php _e('or there is a problem with API KEY'); ?> <?php echo $field['api_key']; ?></p>
    319                 <?php 
     322                <?php
    320323                endif;
    321             }   
     324            }
    322325            ?>
    323326        </div>
    324        
    325         <?php 
     327
     328        <?php
    326329        if (!empty($sets['photoset'])) {
    327330            foreach($sets['photoset'] as $set_key => $set) {
     
    330333            }
    331334        }
    332            
     335
    333336        // no choices
    334337        if(empty($field['choices']))
     
    337340            return false;
    338341        }
    339        
     342
    340343        // html
    341344        if (!isset($multiple)) { $multiple = ''; }
    342         echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . '  data-max-selectable="'. $field['flickr_max_selected'] .'" data-flickr-type="'. $field['flickr_content_type'] .'" >'; 
    343        
     345        echo '<select id="' . $field['name'] . '" class="' . $field['class'] . '" name="' . $field['name'] . '" ' . $multiple . '  data-max-selectable="'. $field['flickr_max_selected'] .'" data-flickr-type="'. $field['flickr_content_type'] .'" >';
     346
    344347        // null
    345348        if($field['required'] == '1')
     
    347350            echo '<option value="null"> - Select - </option>';
    348351        }
    349        
     352
    350353        // loop through values and add them as options
    351354        foreach($field['choices'] as $key => $value)
     
    355358                // this select is grouped with optgroup
    356359                if($key != '') echo '<optgroup label="'.$key.'">';
    357                
     360
    358361                if($value)
    359362                {
     
    373376                                $selected = 'selected="selected"';
    374377                            }
    375                         }   
     378                        }
    376379                        echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>';
    377380                    }
    378381                }
    379                
     382
    380383                if($key != '') echo '</optgroup>';
    381384            }
     
    395398                        $selected = 'selected="selected"';
    396399                    }
    397                 }   
     400                }
    398401                echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
    399402            }
    400            
     403
    401404        }
    402405
    403406        echo '</select>';
    404        
    405     }
    406        
     407
     408    }
     409
    407410    /*
    408411    *  input_admin_enqueue_scripts()
     
    420423
    421424    function input_admin_enqueue_scripts() {
    422        
     425
    423426        $dir = plugin_dir_url( __FILE__ );
    424        
     427
    425428        // register & include JS
    426429        wp_register_script( 'acf-flickr-init', "{$dir}js/flickr-acf5.js" );
    427430        wp_enqueue_script('acf-flickr-init');
    428        
     431
    429432        // register & include CSS
    430         wp_register_style( 'acf-input-flickr', "{$dir}css/input.css" ); 
     433        wp_register_style( 'acf-input-flickr', "{$dir}css/input.css" );
    431434        wp_enqueue_style('acf-input-flickr');
    432        
    433     }
    434    
    435    
     435
     436    }
     437
     438
    436439    /*
    437440    *  input_admin_footer()
     
    449452
    450453    /*
    451        
     454
    452455    function input_admin_footer() {
    453    
    454        
    455        
    456     }
    457    
    458     */
    459    
    460    
     456
     457
     458
     459    }
     460
     461    */
     462
     463
    461464    /*
    462465    *  field_group_admin_enqueue_scripts()
     
    474477
    475478    /*
    476    
     479
    477480    function field_group_admin_enqueue_scripts() {
    478        
    479     }
    480    
    481     */
    482 
    483    
     481
     482    }
     483
     484    */
     485
     486
    484487    /*
    485488    *  field_group_admin_head()
     
    497500
    498501    /*
    499    
     502
    500503    function field_group_admin_head() {
    501    
    502     }
    503    
     504
     505    }
     506
    504507    */
    505508
     
    531534
    532535        return $data;
    533        
    534     }
    535    
    536    
    537    
     536
     537    }
     538
     539
     540
    538541    /*
    539542    *  update_value()
     
    550553    *  @return  $value
    551554    */
    552    
    553     /*
    554    
     555
     556    /*
     557
    555558    function update_value( $value, $post_id, $field ) {
    556        
     559
    557560        return $value;
    558        
    559     }
    560    
    561     */
    562    
    563    
     561
     562    }
     563
     564    */
     565
     566
    564567    /*
    565568    *  format_value()
     
    577580    *  @return  $value
    578581    */
    579        
    580    
     582
     583
    581584    function format_value( $value, $post_id, $field ) {
    582585        // bail early if no value
     
    585588        }
    586589        if (!empty($value['items'])) {
    587             // Decode JSON format that is used in the database 
     590            // Decode JSON format that is used in the database
    588591            $value['items'] = json_decode($value['items']);
    589592
     
    591594            require_once(dirname(__FILE__) . '/phpFlickr.php');
    592595            $f = new phpFlickr($value['api_key']);
    593            
     596
    594597            // enable phpFlickr caching if possible
    595598            $cache_dir = dirname(__FILE__) . '/cache';
    596599            if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) {
    597600                $duration = $field['flickr_cache_duration'] * 60;
    598                 $f->enableCache('fs', $cache_dir, $duration);       
    599             }   
     601                $f->enableCache('fs', $cache_dir, $duration);
     602            }
    600603
    601604            if ($value['type'] == 'sets' || $value['type'] == 'galleries') {
     
    606609                        $photos = $f->photosets_getPhotos($id, 'url_o');
    607610                        $name = 'photoset';
    608                     } 
     611                    }
    609612                    elseif ($value['type'] == 'galleries') {
    610613                        $photos = $f->galleries_getPhotos($id, 'url_o');
     
    617620                        $sets[$id][$photo['id']]['large']    = ($value['large_size'] == 'original') ? $photo['url_o'] : $f->buildPhotoURL($photo, $value['large_size']);
    618621                        $sets[$id][$photo['id']]['photo_id'] = $photo['id'];
    619                     }   
     622                    }
    620623                }
    621624                $value['items'] = $sets;
     
    623626            elseif($value['type'] == 'photostream') {
    624627                $items = array();
    625                
    626                 foreach($value['items'] as $photo) {       
     628
     629                foreach($value['items'] as $photo) {
    627630                    $items[] = array(
    628631                        'title'    => $photo->title,
     
    635638            }
    636639        }
    637        
     640
    638641        return $value;
    639642    }
    640    
     643
    641644}
    642645
  • flickr-field-for-advanced-custom-fields/trunk/acf-flickr.php

    r1110273 r1208950  
    44Plugin URI: https://github.com/phuisman88/flickrfield
    55Description: Flickr field for Advanced Custom Fields. Display items from your photostream or entire sets/galleries along with your WordPress content.
    6 Version: 1.0.5
     6Version: 1.0.6
    77Author: Paul Huisman
    88Author URI: www.paulhuisman.com
     
    1313// set text domain
    1414// Reference: https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
    15 load_plugin_textdomain( 'acf-flickr', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); 
     15load_plugin_textdomain( 'acf-flickr', false, dirname( plugin_basename(__FILE__) ) . '/lang/' );
    1616
    1717// Include field type for ACF5
     
    2020    include_once('acf-flickr-v5.php');
    2121}
    22 add_action('acf/include_field_types', 'include_field_types_flickr');   
     22add_action('acf/include_field_types', 'include_field_types_flickr');
    2323
    2424// Include field type for ACF4
     
    2626    include_once('acf-flickr-v4.php');
    2727}
    28 add_action('acf/register_fields', 'register_fields_flickr');   
     28add_action('acf/register_fields', 'register_fields_flickr');
    2929
    3030?>
  • flickr-field-for-advanced-custom-fields/trunk/readme.txt

    r1110271 r1208950  
    44Requires at least: 3.0.1
    55Tested up to: 4.1.1
    6 Stable tag: 1.0.5
     6Stable tag: 1.0.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2020== Installation ==
    2121
    22 1. Make sure you have Advanced Custom Fields **v4** or **v5** installed. Get it at http://www.advancedcustomfields.com/. 
     221. Make sure you have Advanced Custom Fields **v4** or **v5** installed. Get it at http://www.advancedcustomfields.com/.
    23232. Upload the `flickr field` directory to the `/wp-content/plugins/` directory
    24243. Activate the plugin through the 'Plugins' menu in WordPress
     
    5656== Changelog ==
    5757
     58= 1.0.6 =
     59* Small bugfix to get rid of notification
     60
    5861= 1.0.5 =
    5962* Added feature to limit the maximum selectable amount of sets/photos
Note: See TracChangeset for help on using the changeset viewer.