Changeset 2046394
- Timestamp:
- 03/08/2019 06:14:12 AM (7 years ago)
- Location:
- master-link/trunk
- Files:
-
- 102 added
- 12 edited
-
admin.js (modified) (4 diffs)
-
composer.json (added)
-
composer.lock (added)
-
finders/base.php (modified) (1 diff)
-
finders/deezer.php (modified) (1 diff)
-
finders/itunes.php (modified) (1 diff)
-
finders/spotify.php (modified) (2 diffs)
-
finders/tidal.php (added)
-
images/music-tidal.svg (added)
-
master-link.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
scripts.js (modified) (2 diffs)
-
settings.php (modified) (2 diffs)
-
templates/metabox.php (modified) (1 diff)
-
templates/metabox_row.php (modified) (1 diff)
-
templates/settings.php (modified) (1 diff)
-
vendor (added)
-
vendor/autoload.php (added)
-
vendor/composer (added)
-
vendor/composer/ClassLoader.php (added)
-
vendor/composer/LICENSE (added)
-
vendor/composer/autoload_classmap.php (added)
-
vendor/composer/autoload_namespaces.php (added)
-
vendor/composer/autoload_psr4.php (added)
-
vendor/composer/autoload_real.php (added)
-
vendor/composer/autoload_static.php (added)
-
vendor/composer/installed.json (added)
-
vendor/jwilsson (added)
-
vendor/jwilsson/spotify-web-api-php (added)
-
vendor/jwilsson/spotify-web-api-php/.gitignore (added)
-
vendor/jwilsson/spotify-web-api-php/.travis.yml (added)
-
vendor/jwilsson/spotify-web-api-php/CHANGELOG.md (added)
-
vendor/jwilsson/spotify-web-api-php/CONTRIBUTING.md (added)
-
vendor/jwilsson/spotify-web-api-php/LICENSE.md (added)
-
vendor/jwilsson/spotify-web-api-php/README.md (added)
-
vendor/jwilsson/spotify-web-api-php/composer.json (added)
-
vendor/jwilsson/spotify-web-api-php/docs (added)
-
vendor/jwilsson/spotify-web-api-php/docs/README.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/access-token-with-authorization-code-flow.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/access-token-with-client-credentials-flow.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/changing-return-type.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/controlling-user-playback.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/fetching-catalog-information.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/fetching-spotify-featured-content.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/following-artists-playlists-and-users.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/handling-errors.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/managing-user-library.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/managing-user-playlists.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/managing-user-profiles.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/searching-the-spotify-catalog.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/examples/working-with-scopes.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/getting-started.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/method-reference (added)
-
vendor/jwilsson/spotify-web-api-php/docs/method-reference/Request.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/method-reference/Session.md (added)
-
vendor/jwilsson/spotify-web-api-php/docs/method-reference/SpotifyWebAPI.md (added)
-
vendor/jwilsson/spotify-web-api-php/phpcs.xml (added)
-
vendor/jwilsson/spotify-web-api-php/phpunit.php (added)
-
vendor/jwilsson/spotify-web-api-php/phpunit.xml.dist (added)
-
vendor/jwilsson/spotify-web-api-php/src (added)
-
vendor/jwilsson/spotify-web-api-php/src/Request.php (added)
-
vendor/jwilsson/spotify-web-api-php/src/Session.php (added)
-
vendor/jwilsson/spotify-web-api-php/src/SpotifyWebAPI.php (added)
-
vendor/jwilsson/spotify-web-api-php/src/SpotifyWebAPIAuthException.php (added)
-
vendor/jwilsson/spotify-web-api-php/src/SpotifyWebAPIException.php (added)
-
vendor/jwilsson/spotify-web-api-php/src/cacert.pem (added)
-
vendor/jwilsson/spotify-web-api-php/tests (added)
-
vendor/jwilsson/spotify-web-api-php/tests/RequestTest.php (added)
-
vendor/jwilsson/spotify-web-api-php/tests/SessionTest.php (added)
-
vendor/jwilsson/spotify-web-api-php/tests/SpotifyWebAPITest.php (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/access-token.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/album-tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/album.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/albums.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/artist-albums.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/artist-related-artists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/artist-top-tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/artist.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/artists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/audio-analysis.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/audio-features.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/available-genre-seeds.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/categories-list.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/category-playlists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/category.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/featured-playlists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/my-playlists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/new-releases.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/recently-played.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/recommendations.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/refresh-token-no-refresh-token.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/refresh-token.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/search-album.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/snapshot-id.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/top-artists-and-tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/track.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-albums-contains.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-albums.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-current-playback-info.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-current-track.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-devices.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-followed-artists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-follows-playlist.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-follows.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-playlist-tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-playlist.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-playlists.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-tracks-contains.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user-tracks.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/user.json (added)
-
vendor/jwilsson/spotify-web-api-php/tests/fixtures/users-follows-playlist.json (added)
Legend:
- Unmodified
- Added
- Removed
-
master-link/trunk/admin.js
r1896826 r2046394 1 // Generated by CoffeeScript 1.10.01 // Generated by CoffeeScript 2.3.2 2 2 (function() { 3 3 var checkUPC, checkValidation, setupFields, setupSortable; … … 47 47 barcode = '0' + barcode; 48 48 } 49 // check length 49 50 if (barcode.length < 8 || barcode.length > 18 || (barcode.length !== 8 && barcode.length !== 13 && barcode.length !== 14 && barcode.length !== 18)) { 50 51 return false; … … 53 54 checkSum = 0; 54 55 if (isNaN(lastDigit)) { 55 return false; 56 return false; // not a valid upc/ean 56 57 } 57 58 arr = barcode.substring(0, barcode.length - 1).split("").reverse(); 58 59 oddTotal = 0; 59 60 evenTotal = 0; 60 for (i = j = 0, ref = arr.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {61 for (i = j = 0, ref = arr.length; (0 <= ref ? j < ref : j > ref); i = 0 <= ref ? ++j : --j) { 61 62 if (isNaN(arr[i])) { 62 63 return false; … … 69 70 } 70 71 checkSum = 10 - ((evenTotal + oddTotal) % 10); 72 // true if they are equal 71 73 return checkSum === lastDigit; 72 74 }; -
master-link/trunk/finders/base.php
r1435539 r2046394 1 1 <?php 2 2 interface MasterLinkIFinder { 3 public function find($upc );3 public function find($upc,$name); 4 4 } 5 5 ?> -
master-link/trunk/finders/deezer.php
r1446305 r2046394 6 6 } 7 7 8 public function find($upc ) {8 public function find($upc,$name) { 9 9 $searchData = $this->getData($upc); 10 10 if(isset($searchData->id)) { 11 11 $return = array(); 12 12 $return['id'] = $searchData->id; 13 $return['cover'] = $searchData->cover_ big;13 $return['cover'] = $searchData->cover_xl; 14 14 return $return; 15 15 } else { -
master-link/trunk/finders/itunes.php
r1446305 r2046394 6 6 } 7 7 8 public function find($upc ) {8 public function find($upc,$name) { 9 9 $searchData = $this->getData($upc); 10 10 if($searchData->resultCount > 0) { -
master-link/trunk/finders/spotify.php
r1446305 r2046394 4 4 5 5 public function __construct() { 6 $spotifyAuthToken = get_option('master_link_plugin_spotify_auth'); 7 if($spotifyAuthToken == NULL) { 8 throw new Exception('Spotify authentication not setup'); 9 } 6 10 } 7 11 8 public function find($upc ) {12 public function find($upc,$name) { 9 13 $searchData = $this->getData($upc); 10 14 if(isset($searchData->albums->items[0])) { 11 15 $return = array(); 12 16 $return['id'] = str_replace("https://open.spotify.com/","",$searchData->albums->items[0]->external_urls->spotify); 13 $return['cover'] = $searchData->albums->i mages[0]->url;17 $return['cover'] = $searchData->albums->items[0]->images[0]->url; 14 18 return $return; 15 19 } else { … … 25 29 $ch = curl_init(); 26 30 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 31 curl_setopt($ch, CURLOPT_HTTPHEADER, array( 32 'Authorization: Bearer '.get_option('record_label_spotify_auth'), 33 'x-requested-wth: XMLHttpRequest', 34 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36', 35 )); 27 36 curl_setopt($ch, CURLOPT_URL, $this->searchURI($upc)); 28 37 $result = curl_exec($ch); -
master-link/trunk/master-link.php
r1896826 r2046394 6 6 Author: Greg Tangey 7 7 Author URI: http://ignite.digitalignition.net/ 8 Version: 0. 2.68 Version: 0.3.0 9 9 */ 10 10 … … 160 160 "image" => "music-google_play.svg", 161 161 "verb" => "Buy", 162 ), 163 "tidal" => array( 164 "href" => "https://tidal.com/au/store/%s", 165 "name" => "Tidal", 166 "validation" => "^\d+$", 167 "validation-error" => "Must be a Tidal ID eg. 66437760", 168 "image" => "music-tidal.svg", 169 "verb" => "Play", 162 170 ), 163 171 "other" => array( … … 367 375 $key = "master_link_upc"; 368 376 $val = sanitize_text_field($_REQUEST['master_link_upc']); 377 $title = $post->post_title; 378 $subtitle = sanitize_text_field($_REQUEST['master_link_subtitle']); 379 380 $query = $subtitle . " " . $title; 381 369 382 if($val != "") { 370 $this->updateItunesAndAppleMusic($post_id,$val); 371 $this->updateSpotify($post_id,$val); 372 $this->updateDeezer($post_id,$val); 383 $this->updateItunesAndAppleMusic($post_id,$val,$query); 384 $this->updateSpotify($post_id,$val,$query); 385 $this->updateDeezer($post_id,$val,$query); 386 $this->updateTidal($post_id,$val,$query); 373 387 } 374 388 update_post_meta( $post_id, $key, $val ); … … 392 406 393 407 function updateItunesAndAppleMusic($post_id,$upc) { 394 if($itunes = $this->findItunes($upc )) {408 if($itunes = $this->findItunes($upc,$query)) { 395 409 update_post_meta($post_id,"master_link_plugin-itunes_link_id",$itunes['id']); 396 410 update_post_meta($post_id,"master_link_plugin-applemusic_link_id",$itunes['id']); … … 400 414 401 415 function updateDeezer($post_id,$upc) { 402 if($deezer = $this->findDeezer($upc )) {416 if($deezer = $this->findDeezer($upc,$query)) { 403 417 update_post_meta($post_id,"master_link_plugin-deezer_link_id",$deezer['id']); 404 418 $this->updatePostImageIfImageNotExist($post_id, $deezer['cover']); … … 407 421 408 422 function updateSpotify($post_id,$upc) { 409 if($spotify = $this->findSpotify($upc )) {423 if($spotify = $this->findSpotify($upc,$query)) { 410 424 update_post_meta($post_id,"master_link_plugin-spotify_link_id",$spotify['id']); 411 425 $this->updatePostImageIfImageNotExist($post_id, $spotify['cover']); … … 413 427 } 414 428 415 function findItunes($upc) { 429 function updateTidal($post_id,$upc,$query) { 430 if($tidal = $this->findTidal($upc,$query)) { 431 update_post_meta($post_id,"master_link_plugin-tidal_link_id",$tidal['id']); 432 } 433 } 434 435 function findItunes($upc,$query) { 416 436 require_once "finders/base.php"; 417 437 require_once "finders/itunes.php"; 418 438 $finder = new MasterLinkiTunesFinder(); 419 return $finder->find($upc );420 } 421 422 function findDeezer($upc ) {439 return $finder->find($upc,$query); 440 } 441 442 function findDeezer($upc,$query) { 423 443 require_once "finders/base.php"; 424 444 require_once "finders/deezer.php"; 425 445 $finder = new MasterLinkDeezerFinder(); 426 return $finder->find($upc );427 } 428 429 function findSpotify($upc ) {446 return $finder->find($upc,$query); 447 } 448 449 function findSpotify($upc,$query) { 430 450 require_once "finders/base.php"; 431 451 require_once "finders/spotify.php"; 432 452 $finder = new MasterLinkSpotifyFinder(); 433 return $finder->find($upc); 453 return $finder->find($upc,$query); 454 } 455 456 function findTidal($upc,$query) { 457 require_once "finders/base.php"; 458 require_once "finders/tidal.php"; 459 $finder = new MasterLinkTidalFinder(); 460 return $finder->find($upc,$query); 434 461 } 435 462 -
master-link/trunk/readme.txt
r1896826 r2046394 2 2 Contributors: ruxton 3 3 Donate link: https://ignite.digitalignition.net/code/master-link-wordpress-plugin/ 4 Tags: links, app store, digital storefronts, deezer, itunes, google play, steam, amazon, soundcloud, youtube 4 Tags: links, app store, digital storefronts, deezer, itunes, google play, steam, amazon, soundcloud, youtube, tidal 5 5 Requires at least: 4.3.1 6 Tested up to: 4.9.67 Stable tag: 0. 2.66 Tested up to: 5.1.0 7 Stable tag: 0.3.0 8 8 9 9 Create links that link to multiple storefronts. Great for music or software that is sold on many digital storefronts … … 22 22 23 23 == Changelog == 24 25 = 0.3.0 = 26 * New finders search based on name when UPC isn't possible 27 * Spotify finder requires authentication with Spotify 24 28 25 29 = 0.2.6 = -
master-link/trunk/scripts.js
r1435539 r2046394 1 // Generated by CoffeeScript 1.10.01 // Generated by CoffeeScript 2.3.2 2 2 (function() { 3 3 var embedSoundcloud, embedYouTubeVideo, setupBarcode; … … 56 56 $info = jQuery("#info"); 57 57 setupBarcode(); 58 // jQuery("#youtube .watch").on "click", (e) -> 59 // youtube_url = e.target.parentElement.href 60 // embedYouTubeVideo(youtube_url) 61 // jQuery("#soundcloud .play").on "click", (e) -> 62 // soundcloud_url = e.target.parentElement.href 63 // embedSoundcloud(soundcloud_url) 58 64 return jQuery(window).scroll(function() { 59 65 var newHeight, wScroll; -
master-link/trunk/settings.php
r1446205 r2046394 48 48 register_setting('master_link_plugin', 'master_link_plugin-slug'); 49 49 register_setting('master_link_plugin', 'master_link_plugin-use_template'); 50 51 $args = array( 52 'type' => 'string', 53 'default' => NULL, 54 ); 55 56 register_setting('master_link_plugin', 'master_link_plugin_spotify_client_id', $args); 57 register_setting('master_link_plugin', 'master_link_plugin_spotify_client_secret', $args); 58 register_setting('master_link_plugin', 'master_link_plugin_spotify_auth', $args); 59 60 add_settings_section( 61 'master_link_plugin_spotify_client_settings', 62 __( 'Spotify Client Settings', 'master_link' ), 63 null, 64 'master_link_plugin' 65 ); 66 67 add_settings_section( 68 'master_link_plugin_spotify_auth_settings', 69 __( 'Spotify Authentication Settings', 'master_link' ), 70 array($this,'spotify_auth_settings'), 71 'master_link_plugin_auth_settings' 72 ); 73 74 add_settings_field( 75 'master_link_plugin_spotify_auth', 76 __('Spotify authentication token','master_link'), 77 array($this,'disabled_text_callback'), 78 'master_link_plugin', 79 'master_link_plugin_spotify_auth_settings', 80 array( 81 'name' => 'master_link_plugin_spotify_auth' 82 ) 83 ); 84 85 add_settings_field( 86 'master_link_plugin_spotify_client_id', 87 __('Spotify Client ID','master_link'), 88 array($this,'text_callback'), 89 'master_link_plugin', 90 'master_link_plugin_spotify_client_settings', 91 array( 92 'name' => 'master_link_plugin_spotify_client_id' 93 ) 94 ); 95 96 add_settings_field( 97 'master_link_plugin_spotify_client_secret', 98 __('Spotify Client Secret','master_link'), 99 array($this,'text_callback'), 100 'master_link_plugin', 101 'master_link_plugin_spotify_client_settings', 102 array( 103 'name' => 'master_link_plugin_spotify_client_secret' 104 ) 105 ); 106 } 107 108 function spotify_auth_settings() { 109 require 'vendor/autoload.php'; 110 111 $buttonText = "Connect to Spotify"; 112 113 $session = new SpotifyWebAPI\Session( 114 get_option('master_link_plugin_spotify_client_id'), 115 get_option('master_link_plugin_spotify_client_secret'), 116 menu_page_url('master_link_plugin',false) 117 ); 118 $api = new SpotifyWebAPI\SpotifyWebAPI(); 119 120 if(isset($_GET['code'])) { 121 $session->requestAccessToken($_GET['code']); 122 update_option('master_link_plugin_spotify_auth',$session->getAccessToken(),true); 123 $buttonText = "Reconnect to Spotify"; 124 } 125 elseif(get_option('master_link_plugin_spotify_auth') != NULL) { 126 $buttonText = "Reconnect to Spotify"; 127 } 128 129 $options = [ 130 'scope' => [ 131 'user-read-email', 132 ], 133 ]; 134 135 echo "<a href=\"".$session->getAuthorizeUrl($options)."\" class=\"button primary\">".$buttonText."</a>"; 50 136 } 51 137 … … 117 203 } 118 204 205 function text_callback(array $args) { 206 $option = get_option( $args['name'] ); 207 echo "<input type=\"text\" class=\"large-text\" name=\"" . $args['name'] . "\" value=\"".$option."\" />"; 208 } 209 210 function disabled_text_callback(array $args) { 211 $option = get_option( $args['name'] ); 212 echo "<input type=\"text\" class=\"large-text\" disabled name=\"" . $args['name'] . "\" value=\"".$option."\" />"; 213 } 214 119 215 } 120 216 } -
master-link/trunk/templates/metabox.php
r1435539 r2046394 12 12 <span class="add button-primary alignright"><?php _e('Add Link'); ?></span> 13 13 <table class="form-table striped sortable"> 14 <col width="15%"/> 15 <col/> 16 <col width="8%"/> 17 <col width="10%"/> 14 18 <thead> 15 19 <tr> -
master-link/trunk/templates/metabox_row.php
r1420662 r2046394 1 1 <tr class="master_link_row"> 2 2 <td scope="row"> 3 <select name="master_link_service[<?php echo $serviceCount; ?>][service]" class="regular-text">3 <select name="master_link_service[<?php echo $serviceCount; ?>][service]"> 4 4 <?php foreach($this->services as $services_service_id => $service) : ?> 5 5 <?php $selected = ($services_service_id == $service_id); ?> -
master-link/trunk/templates/settings.php
r1420662 r2046394 8 8 <?php submit_button(); ?> 9 9 </form> 10 <?php 11 $client_id = get_option('master_link_plugin_spotify_client_id'); 12 $client_secret= get_option('master_link_plugin_spotify_client_secret'); 13 14 if(isset($client_id) && isset($client_secret)) { 15 echo "<h3>".__("Spotify Authentication Settings","master_link_plugin")."</h3>\n"; 16 echo '<table class="form-table">'; 17 $this->spotify_auth_settings(); 18 do_settings_fields('master_link_plugin','master_link_plugin_spotify_auth_settings'); 19 echo '</table>'; 20 } 21 ?> 10 22 </div>
Note: See TracChangeset
for help on using the changeset viewer.