Changeset 1208950
- Timestamp:
- 07/29/2015 11:52:47 AM (11 years ago)
- Location:
- flickr-field-for-advanced-custom-fields/trunk
- Files:
-
- 4 edited
-
acf-flickr-v4.php (modified) (36 diffs)
-
acf-flickr-v5.php (modified) (37 diffs)
-
acf-flickr.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v4.php
r1110271 r1208950 2 2 3 3 class acf_field_flickr extends acf_field { 4 4 5 5 // vars 6 6 var $settings, // will hold info such as dir / path 7 7 $defaults; // will hold default field options 8 9 8 9 10 10 /* 11 11 * __construct … … 16 16 * @date 23/01/13 17 17 */ 18 18 19 19 function __construct() 20 20 { … … 24 24 $this->category = __("Content", 'acf'); // Basic, Content, Choice, etc 25 25 $this->defaults = array( 26 // add default here to merge into your field. 26 // add default here to merge into your field. 27 27 'flickr_api_key' => '', 28 28 'flickr_user_id' => '', … … 35 35 'flickr_cache_duration' => '168', 36 36 ); 37 38 37 38 39 39 // do not delete! 40 40 parent::__construct(); 41 42 41 42 43 43 // settings 44 44 $this->settings = array( … … 49 49 50 50 } 51 52 51 52 53 53 /* 54 54 * create_options() … … 63 63 * @param $field - an array holding all the field's data 64 64 */ 65 65 66 66 function create_options( $field ) { 67 67 // defaults? … … 69 69 $field = array_merge($this->defaults, $field); 70 70 */ 71 71 72 72 // key is needed in the field names to correctly save the data 73 $key = $field['name']; 74 73 $key = $field['name']; 74 75 75 // Create Fields 76 ?> 76 ?> 77 77 <tr class="field_option field_option_<?php echo $this->name; ?>"> 78 78 <td class="label"> … … 81 81 </td> 82 82 <td> 83 <?php 83 <?php 84 84 do_action('acf/create_field', array( 85 85 'type' => 'text', 86 86 'name' => 'fields['.$key.'][flickr_user_id]', 87 87 'value' => $field['flickr_user_id'], 88 )); 88 )); 89 89 ?> 90 90 </td> … … 96 96 </td> 97 97 <td> 98 <?php 98 <?php 99 99 do_action('acf/create_field', array( 100 100 'type' => 'text', 101 101 'name' => 'fields['.$key.'][flickr_api_key]', 102 102 'value' => $field['flickr_api_key'], 103 )); 104 ?> 105 </td> 106 </tr> 103 )); 104 ?> 105 </td> 106 </tr> 107 107 <tr class="field_option field_option_<?php echo $this->name; ?>"> 108 108 <td class="label"> … … 148 148 ?> 149 149 </td> 150 </tr> 150 </tr> 151 151 <tr class="field_option field_option_<?php echo $this->name; ?>"> 152 152 <td class="label"> … … 168 168 <label><?php _e( 'Enable cache', 'acf-flickr' );?></label> 169 169 <p class="description"> 170 <?php 170 <?php 171 171 $cache_dir = dirname(__FILE__) . '/cache'; 172 if (! is_writeable($cache_dir)) { 172 if (! is_writeable($cache_dir)) { 173 173 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'); 174 174 } … … 199 199 </td> 200 200 <td> 201 <?php 201 <?php 202 202 do_action('acf/create_field', array( 203 203 'type' => 'text', 204 204 'name' => 'fields['.$key.'][flickr_cache_duration]', 205 205 'value' => $field['flickr_cache_duration'], 206 )); 206 )); 207 207 ?> 208 208 </td> … … 255 255 </tr> 256 256 <?php 257 257 258 258 } 259 260 259 260 261 261 /* 262 262 * create_field() … … 270 270 * @date 23/01/13 271 271 */ 272 272 273 273 function create_field( $field ) { 274 274 // Defaults 275 275 $field['value'] = isset($field['value']) ? $field['value'] : array(); 276 276 $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false; 277 277 278 278 // Get all Flickr sets by the given user ID and api key (both required) 279 279 require_once(dirname(__FILE__) . '/phpFlickr.php'); 280 280 $f = new phpFlickr($field['flickr_api_key']); 281 281 282 282 // Caching 283 283 $cache_dir = dirname(__FILE__) . '/cache'; 284 284 if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) { 285 285 $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 289 289 $field['choices'] = array(); 290 290 $field['choices'][''] = ''; 291 291 ?> 292 292 293 293 <div class="field_form flickr_field type_<?php echo $field['flickr_content_type']; ?>"> 294 294 <?php 295 295 $items = array(); 296 $items = json_decode($field['value']['items']); 296 297 if (isset($field['value']['items'])) { 298 $items = json_decode($field['value']['items']); 299 } 297 300 298 301 // Check for three types of Flickr content; Sets, Galleries and Photostream … … 300 303 if ($field['flickr_content_type'] == 'sets') { 301 304 $flickr_data = $f->photosets_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1); 302 } 305 } 303 306 elseif ($field['flickr_content_type'] == 'galleries') { 304 307 $flickr_data = $f->galleries_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1); … … 308 311 <table class="acf_input widefat acf_field_form_table"> 309 312 <tbody> 310 <?php 313 <?php 311 314 if (is_array($flickr_data) && !empty($flickr_data)) { 312 315 if ($field['flickr_content_type'] == 'sets') { 313 316 $data = $flickr_data['photoset']; 314 } 317 } 315 318 elseif ($field['flickr_content_type'] == 'galleries') { 316 319 $data = $flickr_data['galleries']['gallery']; … … 331 334 <p class="meta_data"> 332 335 <?php _e('Added on');?> <?php echo date_i18n(get_option('date_format') ,$flickr['date_create']); echo ' | '; 333 echo $flickr['count_views'];?> <?php _e('views on Flickr'); 336 echo $flickr['count_views'];?> <?php _e('views on Flickr'); 334 337 echo ' | '; 335 338 echo $flickr['photos'];?> <?php _e('Photos'); … … 343 346 <?php 344 347 } 345 } 348 } 346 349 else { 347 350 ?><tr class="field_label"> 348 351 <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> 349 352 </tr><?php 350 } 353 } 351 354 ?> 352 355 </tbody> … … 356 359 elseif($field['flickr_content_type'] == 'photostream') { 357 360 $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], ''); 358 361 359 362 if (is_array($flickr_data['photos']) && isset($flickr_data['photos']['photo'][0])): ?> 360 363 <ul class="field_label photostream"> 361 364 <?php foreach($flickr_data['photos']['photo'] as $key => $photo): ?> 362 <?php 365 <?php 363 366 $active = ''; 364 367 if (is_array($items)) { … … 371 374 } 372 375 ?> 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']; ?>" 375 378 data-flickr-server="<?php echo $photo['server']; ?>" 376 379 data-flickr-secret="<?php echo $photo['secret']; ?>" … … 385 388 <?php else: ?> 386 389 <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 388 391 endif; 389 } 392 } 390 393 ?> 391 394 </div> 392 393 <?php 395 396 <?php 394 397 if (!empty($sets['photoset'])) { 395 398 foreach($sets['photoset'] as $set_key => $set) { … … 398 401 } 399 402 } 400 403 401 404 // no choices 402 405 if(empty($field['choices'])) … … 405 408 return false; 406 409 } 407 410 408 411 // html 409 412 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 412 415 // null 413 416 if($field['required'] == '1') … … 415 418 echo '<option value="null"> - Select - </option>'; 416 419 } 417 420 418 421 // loop through values and add them as options 419 422 foreach($field['choices'] as $key => $value) … … 423 426 // this select is grouped with optgroup 424 427 if($key != '') echo '<optgroup label="'.$key.'">'; 425 428 426 429 if($value) 427 430 { … … 441 444 $selected = 'selected="selected"'; 442 445 } 443 } 446 } 444 447 echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>'; 445 448 } 446 449 } 447 450 448 451 if($key != '') echo '</optgroup>'; 449 452 } … … 463 466 $selected = 'selected="selected"'; 464 467 } 465 } 468 } 466 469 echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>'; 467 470 } 468 471 469 472 } 470 473 471 474 echo '</select>'; 472 475 473 476 } 474 475 477 478 476 479 /* 477 480 * input_admin_enqueue_scripts() … … 490 493 // register ACF scripts 491 494 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 494 497 // scripts 495 498 wp_enqueue_script(array( 496 'acf-flickr-init', 499 'acf-flickr-init', 497 500 )); 498 501 499 502 // styles 500 503 wp_enqueue_style(array( 501 'acf-input-flickr', 504 'acf-input-flickr', 502 505 )); 503 504 506 507 505 508 } 506 507 509 510 508 511 /* 509 512 * field_group_admin_enqueue_scripts() … … 533 536 * @return $value - the value to be saved in the database 534 537 */ 535 538 536 539 function load_value( $value, $post_id, $field ) 537 540 { … … 547 550 return $data; 548 551 } 549 552 550 553 /* 551 554 * format_value_for_api() … … 563 566 * @return $value - the modified value 564 567 */ 565 568 566 569 function format_value_for_api( $value, $post_id, $field ) 567 570 { 568 571 if (!empty($value['items'])) { 569 // Decode JSON format that is used in the database 572 // Decode JSON format that is used in the database 570 573 $value['items'] = json_decode($value['items']); 571 574 … … 573 576 require_once(dirname(__FILE__) . '/phpFlickr.php'); 574 577 $f = new phpFlickr($value['api_key']); 575 578 576 579 // enable phpFlickr caching if possible 577 580 $cache_dir = dirname(__FILE__) . '/cache'; 578 581 if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) { 579 582 $duration = $field['flickr_cache_duration'] * 60; 580 $f->enableCache('fs', $cache_dir, $duration); 581 } 583 $f->enableCache('fs', $cache_dir, $duration); 584 } 582 585 583 586 if ($value['type'] == 'sets' || $value['type'] == 'galleries') { … … 588 591 $photos = $f->photosets_getPhotos($id, 'url_o'); 589 592 $name = 'photoset'; 590 } 593 } 591 594 elseif ($value['type'] == 'galleries') { 592 595 $photos = $f->galleries_getPhotos($id, 'url_o'); … … 599 602 $sets[$id][$photo['id']]['large'] = ($value['large_size'] == 'original') ? $photo['url_o'] : $f->buildPhotoURL($photo, $value['large_size']); 600 603 $sets[$id][$photo['id']]['photo_id'] = $photo['id']; 601 } 604 } 602 605 } 603 606 $value['items'] = $sets; … … 605 608 elseif($value['type'] == 'photostream') { 606 609 $items = array(); 607 608 foreach($value['items'] as $photo) { 610 611 foreach($value['items'] as $photo) { 609 612 $items[] = array( 610 613 'title' => $photo->title, … … 617 620 } 618 621 } 619 622 620 623 return $value; 621 624 } 622 625 623 626 624 627 } 625 628 -
flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v5.php
r1110271 r1208950 2 2 3 3 class acf_field_flickr extends acf_field { 4 4 5 5 /* 6 6 * __construct … … 15 15 * @return n/a 16 16 */ 17 17 18 18 function __construct() { 19 19 20 20 /* 21 21 * name (string) Single word, no spaces. Underscores allowed 22 22 */ 23 23 24 24 $this->name = 'flickr'; 25 26 25 26 27 27 /* 28 28 * label (string) Multiple words, can include spaces, visible when selecting a field type 29 29 */ 30 30 31 31 $this->label = __('Flickr Field', 'flickr'); 32 33 32 33 34 34 /* 35 35 * category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME 36 36 */ 37 37 38 38 $this->category = 'content'; 39 40 39 40 41 41 /* 42 42 * defaults (array) Array of default settings which are merged into the field object. These are used later in settings 43 43 */ 44 44 45 45 $this->defaults = array( 46 46 'flickr_api_key' => '', … … 54 54 'flickr_cache_duration' => '168', 55 55 ); 56 57 56 57 58 58 // do not delete! 59 59 parent::__construct(); 60 61 } 62 63 60 61 } 62 63 64 64 /* 65 65 * render_field_options() … … 75 75 * @return n/a 76 76 */ 77 77 78 78 function render_field_settings( $field ) { 79 79 acf_render_field_setting( $field, array( … … 91 91 'type' => 'text', 92 92 'name' => 'flickr_api_key', 93 )); 93 )); 94 94 95 95 acf_render_field_setting( $field, array( … … 104 104 ), 105 105 )); 106 106 107 107 acf_render_field_setting( $field, array( 108 108 'label' => __('Display amount','acf-flickr'), … … 135 135 $instructions = '<span style="color:#336600">' . __('The cache folder is writable!', 'acf-flickr') . '</span>'; 136 136 } 137 137 138 138 acf_render_field_setting( $field, array( 139 139 'label' => __('Enable cache','acf-flickr'), … … 153 153 'name' => 'flickr_cache_duration', 154 154 'append' => 'minutes', 155 )); 155 )); 156 156 157 157 acf_render_field_setting( $field, array( … … 163 163 'square' => '75x75 (square)', 164 164 'thumbnail' => '100px (rectangle)', 165 'square_150' => '150x150 (square)', 165 'square_150' => '150x150 (square)', 166 166 'small_240' => '240px (rectangle)', 167 167 'small_320' => '320px (rectangle)', 168 168 ), 169 169 )); 170 170 171 171 acf_render_field_setting( $field, array( 172 172 'label' => __('Large size','acf-flickr'), … … 182 182 ), 183 183 )); 184 185 186 187 } 188 189 190 184 185 186 187 } 188 189 190 191 191 /* 192 192 * render_field() … … 203 203 * @return n/a 204 204 */ 205 205 206 206 function render_field( $field ) { 207 207 // Defaults 208 208 $field['value'] = isset($field['value']) ? $field['value'] : array(); 209 209 $field['optgroup'] = isset($field['optgroup']) ? $field['optgroup'] : false; 210 210 211 211 // Get all Flickr sets by the given user ID and api key (both required) 212 212 require_once(dirname(__FILE__) . '/phpFlickr.php'); 213 213 $f = new phpFlickr($field['flickr_api_key']); 214 214 215 215 // Caching 216 216 $cache_dir = dirname(__FILE__) . '/cache'; 217 217 if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) { 218 218 $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 222 222 $field['choices'] = array(); 223 223 $field['choices'][''] = ''; 224 224 ?> 225 225 226 226 <div class="field_form flickr_field type_<?php echo $field['flickr_content_type']; ?>"> 227 227 <?php 228 228 $items = array(); 229 $items = json_decode($field['value']['items']); 229 230 if (isset($field['value']['items'])) { 231 $items = json_decode($field['value']['items']); 232 } 230 233 231 234 // Check for three types of Flickr content; Sets, Galleries and Photostream … … 233 236 if ($field['flickr_content_type'] == 'sets') { 234 237 $flickr_data = $f->photosets_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1); 235 } 238 } 236 239 elseif ($field['flickr_content_type'] == 'galleries') { 237 240 $flickr_data = $f->galleries_getList($field['flickr_user_id'], $field['flickr_sets_amount'], 1); … … 241 244 <table class="acf_input widefat acf_field_form_table"> 242 245 <tbody> 243 <?php 246 <?php 244 247 if (is_array($flickr_data) && !empty($flickr_data)) { 245 248 if ($field['flickr_content_type'] == 'sets') { 246 249 $data = $flickr_data['photoset']; 247 } 250 } 248 251 elseif ($field['flickr_content_type'] == 'galleries') { 249 252 $data = $flickr_data['galleries']['gallery']; … … 264 267 <p class="meta_data"> 265 268 <?php _e('Added on');?> <?php echo date_i18n(get_option('date_format') ,$flickr['date_create']); echo ' | '; 266 echo $flickr['count_views'];?> <?php _e('views on Flickr'); 269 echo $flickr['count_views'];?> <?php _e('views on Flickr'); 267 270 echo ' | '; 268 271 echo $flickr['photos'];?> <?php _e('Photos'); … … 276 279 <?php 277 280 } 278 } 281 } 279 282 else { 280 283 ?><tr class="field_label"> 281 284 <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> 282 285 </tr><?php 283 } 286 } 284 287 ?> 285 288 </tbody> … … 292 295 <ul class="field_label photostream"> 293 296 <?php foreach($flickr_data['photos']['photo'] as $key => $photo): ?> 294 <?php 297 <?php 295 298 $active = ''; 296 299 if (is_array($items)) { … … 303 306 } 304 307 ?> 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']; ?>" 307 310 data-flickr-server="<?php echo $photo['server']; ?>" 308 311 data-flickr-secret="<?php echo $photo['secret']; ?>" … … 317 320 <?php else: ?> 318 321 <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 320 323 endif; 321 } 324 } 322 325 ?> 323 326 </div> 324 325 <?php 327 328 <?php 326 329 if (!empty($sets['photoset'])) { 327 330 foreach($sets['photoset'] as $set_key => $set) { … … 330 333 } 331 334 } 332 335 333 336 // no choices 334 337 if(empty($field['choices'])) … … 337 340 return false; 338 341 } 339 342 340 343 // html 341 344 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 344 347 // null 345 348 if($field['required'] == '1') … … 347 350 echo '<option value="null"> - Select - </option>'; 348 351 } 349 352 350 353 // loop through values and add them as options 351 354 foreach($field['choices'] as $key => $value) … … 355 358 // this select is grouped with optgroup 356 359 if($key != '') echo '<optgroup label="'.$key.'">'; 357 360 358 361 if($value) 359 362 { … … 373 376 $selected = 'selected="selected"'; 374 377 } 375 } 378 } 376 379 echo '<option value="'.$id.'" '.$selected.'>'.$label.'</option>'; 377 380 } 378 381 } 379 382 380 383 if($key != '') echo '</optgroup>'; 381 384 } … … 395 398 $selected = 'selected="selected"'; 396 399 } 397 } 400 } 398 401 echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>'; 399 402 } 400 403 401 404 } 402 405 403 406 echo '</select>'; 404 405 } 406 407 408 } 409 407 410 /* 408 411 * input_admin_enqueue_scripts() … … 420 423 421 424 function input_admin_enqueue_scripts() { 422 425 423 426 $dir = plugin_dir_url( __FILE__ ); 424 427 425 428 // register & include JS 426 429 wp_register_script( 'acf-flickr-init', "{$dir}js/flickr-acf5.js" ); 427 430 wp_enqueue_script('acf-flickr-init'); 428 431 429 432 // 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" ); 431 434 wp_enqueue_style('acf-input-flickr'); 432 433 } 434 435 435 436 } 437 438 436 439 /* 437 440 * input_admin_footer() … … 449 452 450 453 /* 451 454 452 455 function input_admin_footer() { 453 454 455 456 } 457 458 */ 459 460 456 457 458 459 } 460 461 */ 462 463 461 464 /* 462 465 * field_group_admin_enqueue_scripts() … … 474 477 475 478 /* 476 479 477 480 function field_group_admin_enqueue_scripts() { 478 479 } 480 481 */ 482 483 481 482 } 483 484 */ 485 486 484 487 /* 485 488 * field_group_admin_head() … … 497 500 498 501 /* 499 502 500 503 function field_group_admin_head() { 501 502 } 503 504 505 } 506 504 507 */ 505 508 … … 531 534 532 535 return $data; 533 534 } 535 536 537 536 537 } 538 539 540 538 541 /* 539 542 * update_value() … … 550 553 * @return $value 551 554 */ 552 553 /* 554 555 556 /* 557 555 558 function update_value( $value, $post_id, $field ) { 556 559 557 560 return $value; 558 559 } 560 561 */ 562 563 561 562 } 563 564 */ 565 566 564 567 /* 565 568 * format_value() … … 577 580 * @return $value 578 581 */ 579 580 582 583 581 584 function format_value( $value, $post_id, $field ) { 582 585 // bail early if no value … … 585 588 } 586 589 if (!empty($value['items'])) { 587 // Decode JSON format that is used in the database 590 // Decode JSON format that is used in the database 588 591 $value['items'] = json_decode($value['items']); 589 592 … … 591 594 require_once(dirname(__FILE__) . '/phpFlickr.php'); 592 595 $f = new phpFlickr($value['api_key']); 593 596 594 597 // enable phpFlickr caching if possible 595 598 $cache_dir = dirname(__FILE__) . '/cache'; 596 599 if (is_writeable($cache_dir) && $field['flickr_cache_enabled'] == 1) { 597 600 $duration = $field['flickr_cache_duration'] * 60; 598 $f->enableCache('fs', $cache_dir, $duration); 599 } 601 $f->enableCache('fs', $cache_dir, $duration); 602 } 600 603 601 604 if ($value['type'] == 'sets' || $value['type'] == 'galleries') { … … 606 609 $photos = $f->photosets_getPhotos($id, 'url_o'); 607 610 $name = 'photoset'; 608 } 611 } 609 612 elseif ($value['type'] == 'galleries') { 610 613 $photos = $f->galleries_getPhotos($id, 'url_o'); … … 617 620 $sets[$id][$photo['id']]['large'] = ($value['large_size'] == 'original') ? $photo['url_o'] : $f->buildPhotoURL($photo, $value['large_size']); 618 621 $sets[$id][$photo['id']]['photo_id'] = $photo['id']; 619 } 622 } 620 623 } 621 624 $value['items'] = $sets; … … 623 626 elseif($value['type'] == 'photostream') { 624 627 $items = array(); 625 626 foreach($value['items'] as $photo) { 628 629 foreach($value['items'] as $photo) { 627 630 $items[] = array( 628 631 'title' => $photo->title, … … 635 638 } 636 639 } 637 640 638 641 return $value; 639 642 } 640 643 641 644 } 642 645 -
flickr-field-for-advanced-custom-fields/trunk/acf-flickr.php
r1110273 r1208950 4 4 Plugin URI: https://github.com/phuisman88/flickrfield 5 5 Description: Flickr field for Advanced Custom Fields. Display items from your photostream or entire sets/galleries along with your WordPress content. 6 Version: 1.0. 56 Version: 1.0.6 7 7 Author: Paul Huisman 8 8 Author URI: www.paulhuisman.com … … 13 13 // set text domain 14 14 // Reference: https://codex.wordpress.org/Function_Reference/load_plugin_textdomain 15 load_plugin_textdomain( 'acf-flickr', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); 15 load_plugin_textdomain( 'acf-flickr', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); 16 16 17 17 // Include field type for ACF5 … … 20 20 include_once('acf-flickr-v5.php'); 21 21 } 22 add_action('acf/include_field_types', 'include_field_types_flickr'); 22 add_action('acf/include_field_types', 'include_field_types_flickr'); 23 23 24 24 // Include field type for ACF4 … … 26 26 include_once('acf-flickr-v4.php'); 27 27 } 28 add_action('acf/register_fields', 'register_fields_flickr'); 28 add_action('acf/register_fields', 'register_fields_flickr'); 29 29 30 30 ?> -
flickr-field-for-advanced-custom-fields/trunk/readme.txt
r1110271 r1208950 4 4 Requires at least: 3.0.1 5 5 Tested up to: 4.1.1 6 Stable tag: 1.0. 56 Stable tag: 1.0.6 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 20 20 == Installation == 21 21 22 1. Make sure you have Advanced Custom Fields **v4** or **v5** installed. Get it at http://www.advancedcustomfields.com/. 22 1. Make sure you have Advanced Custom Fields **v4** or **v5** installed. Get it at http://www.advancedcustomfields.com/. 23 23 2. Upload the `flickr field` directory to the `/wp-content/plugins/` directory 24 24 3. Activate the plugin through the 'Plugins' menu in WordPress … … 56 56 == Changelog == 57 57 58 = 1.0.6 = 59 * Small bugfix to get rid of notification 60 58 61 = 1.0.5 = 59 62 * Added feature to limit the maximum selectable amount of sets/photos
Note: See TracChangeset
for help on using the changeset viewer.