Changeset 1306180
- Timestamp:
- 12/11/2015 01:44:33 PM (10 years ago)
- Location:
- flickr-field-for-advanced-custom-fields/trunk
- Files:
-
- 5 added
- 4 edited
-
acf-flickr-v4.php (modified) (13 diffs)
-
acf-flickr-v5.php (modified) (13 diffs)
-
acf-flickr.php (modified) (3 diffs)
-
css/options.css (added)
-
js/options.js (added)
-
phpflickr (added)
-
phpflickr/generate_flickr_token.php (added)
-
phpflickr/phpFlickr.php (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v4.php
r1231799 r1306180 28 28 'flickr_user_id' => '', 29 29 'flickr_content_type' => 'sets', 30 'flickr_private_mode' => 0, 31 'flickr_secret_key' => '', 32 'flickr_private_token' => '', 30 33 'flickr_sets_amount' => '9999', 31 34 'flickr_max_selected' => '0', … … 51 54 } 52 55 56 /* 57 * field_group_admin_enqueue_scripts() 58 * 59 * This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited. 60 * Use this action to add css + javascript to assist your create_field_options() action. 61 * 62 * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts 63 * @type action 64 * @since 3.6 65 * @date 23/01/13 66 */ 67 function field_group_admin_enqueue_scripts() 68 { 69 wp_register_script('acf-input-image-crop-options', $this->settings['dir'] . 'js/options.js', array('jquery'), $this->settings['version']); 70 wp_enqueue_script( 'acf-input-image-crop-options'); 71 wp_register_style('acf-input-image-crop-options', $this->settings['dir'] . 'css/options.css'); 72 wp_enqueue_style( 'acf-input-image-crop-options'); 73 } 53 74 54 75 /* … … 79 100 <td class="label"> 80 101 <label><?php _e('Flickr User ID','acf-flickr'); ?><span class="required">*</span></label> 81 <p class="description">Find your User ID at <a href="http://idgettr.com/" >http://idgettr.com/</a></p>102 <p class="description">Find your User ID at <a href="http://idgettr.com/" target="_blank">http://idgettr.com/</a>. Alternatively, you can set the constant <strong>FLICKR_FIELD_USER_ID</strong>.</p> 82 103 </td> 83 104 <td> … … 94 115 <td class="label"> 95 116 <label><?php _e('Flickr API Key','acf-flickr'); ?><span class="required">*</span></label> 96 <p class="description"><?php _e('Find or register your API key at <a href="http://www.flickr.com/services/apps/" >http://www.flickr.com/services/apps</a>', 'acf-flickr');?></p>117 <p class="description"><?php _e('Find or register your API key at <a href="http://www.flickr.com/services/apps/" target="_blank">http://www.flickr.com/services/apps</a>', 'acf-flickr');?></p> 97 118 </td> 98 119 <td> … … 102 123 'name' => 'fields['.$key.'][flickr_api_key]', 103 124 'value' => $field['flickr_api_key'], 125 )); 126 ?> 127 </td> 128 </tr> 129 <tr class="field_option field_option_<?php echo $this->name; ?>"> 130 <td class="label"> 131 <label><?php _e('Flickr Private Mode','acf-flickr'); ?></label> 132 <p class="description"><?php _e('When private mode is enabled you <strong>need to supply a token</strong> in order to get private photos.', 'acf-flickr');?></p> 133 </td> 134 <td> 135 <?php 136 do_action('acf/create_field', array( 137 'type' => 'radio', 138 'layout' => 'horizontal', 139 'name' => 'fields['.$key.'][flickr_private_mode]', 140 'value' => $field['flickr_private_mode'], 141 'class' => 'flickr_private_mode_select', 142 'choices' => array( 143 '0' => 'Off', 144 '1' => 'On', 145 ), 146 )); 147 ?> 148 </td> 149 </tr> 150 <tr class="field_option field_option_<?php echo $this->name; ?>" data-name="flickr_secret_key"> 151 <td class="label"> 152 <label><?php _e('Flickr Secret Key','acf-flickr'); ?><span class="required">*</span></label> 153 <p class="description"><?php _e('Find or register your secret key at <a href="http://www.flickr.com/services/apps/" target="_blank">http://www.flickr.com/services/apps</a>', 'acf-flickr');?></p> 154 </td> 155 <td> 156 <?php 157 do_action('acf/create_field', array( 158 'type' => 'text', 159 'name' => 'fields['.$key.'][flickr_secret_key]', 160 'value' => $field['flickr_secret_key'], 161 'class' => 'flickr_secret_key', 162 )); 163 ?> 164 </td> 165 </tr> 166 <tr class="field_option field_option_<?php echo $this->name; ?>" data-name="flickr_private_token"> 167 <td class="label"> 168 <label><?php _e('Flickr Private Token','acf-flickr'); ?><span class="required">*</span></label> 169 <p class="description"><?php _e('If you haven\'t got a token yet you can try this modified phpFlickr script <a href="' . plugin_dir_url( __FILE__ ) . 'phpflickr/generate_flickr_token.php" target="_blank">to generate private flickr token</a>. Alternatively, you can set the constant <strong>FLICKR_FIELD_API_TOKEN</strong>.', 'acf-flickr');?></p> 170 </td> 171 <td> 172 <?php 173 do_action('acf/create_field', array( 174 'type' => 'text', 175 'name' => 'fields['.$key.'][flickr_private_token]', 176 'value' => $field['flickr_private_token'], 177 'class' => 'flickr_private_token', 104 178 )); 105 179 ?> … … 184 258 <?php 185 259 do_action('acf/create_field', array( 186 'type' => 'select', 260 'type' => 'radio', 261 'layout' => 'horizontal', 187 262 'name' => 'fields['.$key.'][flickr_cache_enabled]', 188 263 'value' => $field['flickr_cache_enabled'], 189 264 'choices' => array( 190 ' 1' => 'Yes',191 ' 0' => 'No',265 '0' => 'Off', 266 '1' => 'On', 192 267 ), 268 'class' => 'flickr_cache_select', 193 269 )); 194 270 ?> 195 271 </td> 196 272 </tr> 197 <tr class="field_option field_option_<?php echo $this->name; ?>" >273 <tr class="field_option field_option_<?php echo $this->name; ?>" data-name="flickr_cache_duration"> 198 274 <td class="label"> 199 275 <label><?php _e('Cache duration','acf-flickr'); ?></label> 200 <p class="description"><?php _e('The time your cache may last in minutes (this setting will be ignored when your cache is disabled).', 'acf-flickr');?></p>276 <p class="description"><?php _e('The time your cache may last in minutes.', 'acf-flickr');?></p> 201 277 </td> 202 278 <td> … … 294 370 295 371 // Get all Flickr sets by the given user ID and api key (both required) 296 require_once(dirname(__FILE__) . '/phpFlickr.php'); 297 $f = new phpFlickr($field['flickr_api_key']); 372 require_once(dirname(__FILE__) . '/phpflickr/phpFlickr.php'); 373 374 if($field['flickr_private_mode']) { 375 // Private Mode 376 $f = new phpFlickr($field['flickr_api_key'], $field['flickr_secret_key'], true); 377 $f->setToken($field['flickr_private_token']); 378 } 379 else { 380 // Public Mode 381 $f = new phpFlickr($field['flickr_api_key']); 382 } 298 383 299 384 // Caching … … 307 392 } 308 393 309 $field['choices'] = array(); 310 $field['choices'][''] = ''; 394 // Check if user id exists in constants, if so - use that one 395 if(defined('FLICKR_FIELD_USER_ID')) { 396 $field['flickr_user_id'] = FLICKR_FIELD_USER_ID; 397 } 398 399 $field['choices'] = array(array()); 311 400 ?> 312 401 … … 378 467 } 379 468 elseif($field['flickr_content_type'] == 'photostream') { 380 $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], ''); 469 if($field['flickr_private_mode']) { 470 $flickr_data = $f->people_getPhotos($field['flickr_user_id'], array('privacy_filter' => 5, 'per_page' => $field['flickr_sets_amount']) ); 471 } 472 else { 473 $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], ''); 474 } 381 475 382 476 if (is_array($flickr_data['photos']) && isset($flickr_data['photos']['photo'][0])): ?> … … 387 481 if (is_array($items)) { 388 482 foreach ($items as $k => $item) { 389 $item = get_object_vars($item); 390 if(is_array($item) && in_array($photo['id'], $item)) { 391 $active = ' active-row'; 483 if (is_object($item)) { 484 $item = get_object_vars($item); 485 if(is_array($item) && in_array($photo['id'], $item)) { 486 $active = ' active-row'; 487 } 392 488 } 393 489 } … … 568 664 $data['user_id'] = $field['flickr_user_id']; 569 665 $data['api_key'] = $field['flickr_api_key']; 666 $data['private_mode'] = $field['flickr_private_mode']; 667 $data['secret_key'] = $field['flickr_secret_key']; 668 $data['private_token'] = $field['flickr_private_token']; 570 669 571 670 return $data; … … 595 694 596 695 // Initialize a new phpFlickr object based on your api key 597 require_once(dirname(__FILE__) . '/phpFlickr.php'); 598 $f = new phpFlickr($value['api_key']); 696 require_once(dirname(__FILE__) . '/phpflickr/phpFlickr.php'); 697 698 if($value['private_mode']) { 699 // Private Mode 700 $f = new phpFlickr($value['api_key'], $value['secret_key'], true); 701 $f->setToken($value['private_token']); 702 } 703 else { 704 // Public Mode 705 $f = new phpFlickr($value['api_key']); 706 } 599 707 600 708 // enable phpFlickr caching if possible … … 618 726 foreach($value['items'] as $id) { 619 727 if ($value['type'] == 'sets') { 620 $photos = $f->photosets_getPhotos($id, 'url_o', null, $value['flickr_show_limit']); 728 $privacy_filter = $value['private_mode'] == true ? 5 : 1; 729 $photos = $f->photosets_getPhotos($id, 'url_o', $privacy_filter, $value['flickr_show_limit']); 621 730 $name = 'photoset'; 622 731 } -
flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v5.php
r1231799 r1306180 46 46 'flickr_api_key' => '', 47 47 'flickr_user_id' => '', 48 'flickr_private_mode' => 0, 49 'flickr_secret_key' => '', 50 'flickr_private_token' => '', 48 51 'flickr_content_type' => 'sets', 49 52 'flickr_sets_amount' => '9999', … … 81 84 'required' => true, 82 85 'label' => __('Flickr User ID','acf-flickr'), 83 'instructions' => __('Find your User ID at','acf-flickr') . ' <a href="http://idgettr.com/" >http://idgettr.com/</a>',86 'instructions' => __('Find your User ID at','acf-flickr') . ' <a href="http://idgettr.com/" target="_blank">http://idgettr.com/</a>. Alternatively, you can set the constant <strong>FLICKR_FIELD_USER_ID</strong>.', 84 87 'type' => 'text', 85 88 'name' => 'flickr_user_id', … … 89 92 'required' => true, 90 93 'label' => __('Flickr API Key','acf-flickr'), 91 'instructions' => __('Find or register your API key at','acf-flickr') . ' <a href="http://www.flickr.com/services/apps/" >http://www.flickr.com/services/apps</a>',94 'instructions' => __('Find or register your API key at','acf-flickr') . ' <a href="http://www.flickr.com/services/apps/" target="_blank">http://www.flickr.com/services/apps</a>', 92 95 'type' => 'text', 93 96 'name' => 'flickr_api_key', 94 97 )); 98 99 acf_render_field_setting( $field, array( 100 'label' => __('Flickr Private Mode','acf-flickr'), 101 'instructions' => __('When private mode is enabled you <strong>need to supply a token</strong> in order to get private photos.','acf-flickr'), 102 'type' => 'radio', 103 'layout' => 'horizontal', 104 'name' => 'flickr_private_mode', 105 'class' => 'flickr_private_mode_select', 106 'choices' => array( 107 '0' => 'Off', 108 '1' => 'On', 109 ), 110 )); 111 112 acf_render_field_setting( $field, array( 113 'label' => __('Flickr Secret Key','acf-flickr'), 114 'instructions' => __('Find or register your Secret key at','acf-flickr') . ' <a href="http://www.flickr.com/services/apps/" target="_blank">http://www.flickr.com/services/apps</a>', 115 'type' => 'text', 116 'name' => 'flickr_secret_key', 117 'class' => 'flickr_secret_key', 118 )); 119 120 121 acf_render_field_setting( $field, array( 122 'label' => __('Flickr Private Token','acf-flickr'), 123 'instructions' => __('If you haven\'t got a token yet you can try this modified phpFlickr script <a href="' . plugin_dir_url( __FILE__ ) . 'phpflickr/generate_flickr_token.php" target="_blank">to generate private flickr token</a>. Alternatively, you can set the constant <strong>FLICKR_FIELD_API_TOKEN</strong>.', 'acf-flickr'), 124 'type' => 'text', 125 'name' => 'flickr_private_token', 126 'class' => 'flickr_private_token', 127 )); 128 95 129 96 130 acf_render_field_setting( $field, array( … … 112 146 'name' => 'flickr_sets_amount', 113 147 'choices' => array( 114 '10' => '10',115 '20' => '20',116 '30' => '30',117 '40' => '40',118 '50' => '50',119 '100' => '100',120 '9999' => 'Unlimited',148 '10' => '10', 149 '20' => '20', 150 '30' => '30', 151 '40' => '40', 152 '50' => '50', 153 '100' => '100', 154 '9999' => 'Unlimited', 121 155 ), 122 156 )); … … 141 175 'label' => __('Enable cache','acf-flickr'), 142 176 'instructions' => $instructions, 143 'type' => 'select', 177 'type' => 'radio', 178 'layout' => 'horizontal', 144 179 'name' => 'flickr_cache_enabled', 180 'class' => 'flickr_cache_select', 145 181 'choices' => array( 146 ' 1' => 'Yes',147 ' 0' => 'No',182 '0' => 'Off', 183 '1' => 'On', 148 184 ), 149 185 )); … … 151 187 acf_render_field_setting( $field, array( 152 188 'label' => __('Cache duration','acf-flickr'), 153 'instructions' => __('The time your cache may last in minutes (this setting will be ignored when your cache is disabled).','acf-flickr') . ' <a href="http://www.flickr.com/services/apps/">http://www.flickr.com/services/apps</a>',189 'instructions' => __('The time your cache may last in minutes.','acf-flickr'), 154 190 'type' => 'text', 155 191 'name' => 'flickr_cache_duration', 192 'class' => 'flickr_cache_duration', 156 193 'append' => 'minutes', 157 194 )); … … 216 253 217 254 // Get all Flickr sets by the given user ID and api key (both required) 218 require_once(dirname(__FILE__) . '/phpFlickr.php'); 219 $f = new phpFlickr($field['flickr_api_key']); 255 require_once(dirname(__FILE__) . '/phpflickr/phpFlickr.php'); 256 257 if($field['flickr_private_mode']) { 258 // Private Mode 259 $f = new phpFlickr($field['flickr_api_key'], $field['flickr_secret_key'], true); 260 $f->setToken($field['flickr_private_token']); 261 } 262 else { 263 // Public Mode 264 $f = new phpFlickr($field['flickr_api_key']); 265 } 220 266 221 267 // Caching … … 229 275 } 230 276 231 $field['choices'] = array(); 232 $field['choices'][''] = ''; 277 // Check if user id exists in constants, if so - use that one 278 if(defined('FLICKR_FIELD_USER_ID')) { 279 $field['flickr_user_id'] = FLICKR_FIELD_USER_ID; 280 } 281 282 $field['choices'] = array(array()); 233 283 ?> 234 284 … … 300 350 } 301 351 elseif($field['flickr_content_type'] == 'photostream') { 302 $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], ''); 352 if($field['flickr_private_mode']) { 353 $flickr_data = $f->people_getPhotos($field['flickr_user_id'], array('privacy_filter' => 5, 'per_page' => $field['flickr_sets_amount']) ); 354 } 355 else { 356 $flickr_data = $f->people_getPublicPhotos ($field['flickr_user_id'], NULL, 'url_o', $field['flickr_sets_amount'], ''); 357 } 303 358 if (is_array($flickr_data['photos']) && isset($flickr_data['photos']['photo'][0])): ?> 304 359 <ul class="field_label photostream"> … … 485 540 */ 486 541 487 /*488 489 542 function field_group_admin_enqueue_scripts() { 490 491 } 492 493 */ 543 $dir = plugin_dir_url( __FILE__ ); 544 545 wp_register_script('acf-input-flickr-field-options', $dir . 'js/options.js'); 546 wp_enqueue_script( 'acf-input-flickr-field-options'); 547 548 wp_register_style('acf-input-flickr-field-options', $dir . 'css/options.css'); 549 wp_enqueue_style( 'acf-input-flickr-field-options'); 550 } 551 494 552 495 553 … … 542 600 $data['user_id'] = $field['flickr_user_id']; 543 601 $data['api_key'] = $field['flickr_api_key']; 602 $data['private_mode'] = $field['flickr_private_mode']; 603 $data['secret_key'] = $field['flickr_secret_key']; 604 $data['private_token'] = $field['flickr_private_token']; 544 605 545 606 return $data; 546 547 607 } 548 608 … … 602 662 603 663 // Initialize a new phpFlickr object based on your api key 604 require_once(dirname(__FILE__) . '/phpFlickr.php'); 605 $f = new phpFlickr($value['api_key']); 664 require_once(dirname(__FILE__) . '/phpflickr/phpFlickr.php'); 665 666 if($value['private_mode']) { 667 // Private Mode 668 $f = new phpFlickr($value['api_key'], $value['secret_key'], true); 669 $f->setToken($value['private_token']); 670 } 671 else { 672 // Public Mode 673 $f = new phpFlickr($value['api_key']); 674 } 606 675 607 676 // enable phpFlickr caching if possible … … 625 694 foreach($value['items'] as $id) { 626 695 if ($value['type'] == 'sets') { 627 $photos = $f->photosets_getPhotos($id, 'url_o', null, $value['flickr_show_limit']); 696 $privacy_filter = $value['private_mode'] == true ? 5 : 1; 697 698 $photos = $f->photosets_getPhotos($id, 'url_o', $privacy_filter, $value['flickr_show_limit']); 699 628 700 $name = 'photoset'; 629 701 } -
flickr-field-for-advanced-custom-fields/trunk/acf-flickr.php
r1231833 r1306180 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.86 Version: 1.1.0 7 7 Author: Paul Huisman 8 8 Author URI: www.paulhuisman.com … … 18 18 // $version = 5 and can be ignored until ACF6 exists 19 19 function include_field_types_flickr( $version ) { 20 include_once('acf-flickr-v5.php');20 include_once('acf-flickr-v5.php'); 21 21 } 22 22 add_action('acf/include_field_types', 'include_field_types_flickr'); … … 24 24 // Include field type for ACF4 25 25 function register_fields_flickr() { 26 include_once('acf-flickr-v4.php');26 include_once('acf-flickr-v4.php'); 27 27 } 28 28 add_action('acf/register_fields', 'register_fields_flickr'); -
flickr-field-for-advanced-custom-fields/trunk/readme.txt
r1231811 r1306180 3 3 Tags: flickr, acf, custom, fields, photostream, photosets 4 4 Requires at least: 3.0.1 5 Tested up to: 4. 36 Stable tag: 1. 0.85 Tested up to: 4.4 6 Stable tag: 1.1.0 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 56 56 == Changelog == 57 57 58 = 1.1.0 = 59 * Added Private Mode - you can now enable a mode where you can display private photos from Flickr (those that are not publicly available) 60 58 61 = 1.0.8 = 59 62 * Added possibility to set your own cache dir location with constant FLICKR_FIELD_CACHE_DIR
Note: See TracChangeset
for help on using the changeset viewer.