Plugin Directory

Changeset 2046394


Ignore:
Timestamp:
03/08/2019 06:14:12 AM (7 years ago)
Author:
Ruxton
Message:

Release 0.3.0

Location:
master-link/trunk
Files:
102 added
12 edited

Legend:

Unmodified
Added
Removed
  • master-link/trunk/admin.js

    r1896826 r2046394  
    1 // Generated by CoffeeScript 1.10.0
     1// Generated by CoffeeScript 2.3.2
    22(function() {
    33  var checkUPC, checkValidation, setupFields, setupSortable;
     
    4747      barcode = '0' + barcode;
    4848    }
     49    // check length
    4950    if (barcode.length < 8 || barcode.length > 18 || (barcode.length !== 8 && barcode.length !== 13 && barcode.length !== 14 && barcode.length !== 18)) {
    5051      return false;
     
    5354    checkSum = 0;
    5455    if (isNaN(lastDigit)) {
    55       return false;
     56      return false; // not a valid upc/ean
    5657    }
    5758    arr = barcode.substring(0, barcode.length - 1).split("").reverse();
    5859    oddTotal = 0;
    5960    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) {
    6162      if (isNaN(arr[i])) {
    6263        return false;
     
    6970    }
    7071    checkSum = 10 - ((evenTotal + oddTotal) % 10);
     72    // true if they are equal
    7173    return checkSum === lastDigit;
    7274  };
  • master-link/trunk/finders/base.php

    r1435539 r2046394  
    11<?php
    22interface MasterLinkIFinder {
    3   public function find($upc);
     3  public function find($upc,$name);
    44}
    55?>
  • master-link/trunk/finders/deezer.php

    r1446305 r2046394  
    66  }
    77
    8   public function find($upc) {
     8  public function find($upc,$name) {
    99    $searchData = $this->getData($upc);
    1010    if(isset($searchData->id)) {
    1111      $return = array();
    1212      $return['id'] = $searchData->id;
    13       $return['cover'] = $searchData->cover_big;
     13      $return['cover'] = $searchData->cover_xl;
    1414      return $return;
    1515    } else {
  • master-link/trunk/finders/itunes.php

    r1446305 r2046394  
    66  }
    77
    8   public function find($upc) {
     8  public function find($upc,$name) {
    99    $searchData = $this->getData($upc);
    1010    if($searchData->resultCount > 0) {
  • master-link/trunk/finders/spotify.php

    r1446305 r2046394  
    44
    55  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    }
    610  }
    711
    8   public function find($upc) {
     12  public function find($upc,$name) {
    913    $searchData = $this->getData($upc);
    1014    if(isset($searchData->albums->items[0])) {
    1115      $return = array();
    1216      $return['id'] = str_replace("https://open.spotify.com/","",$searchData->albums->items[0]->external_urls->spotify);
    13       $return['cover'] = $searchData->albums->images[0]->url;
     17      $return['cover'] = $searchData->albums->items[0]->images[0]->url;
    1418      return $return;
    1519    } else {
     
    2529    $ch = curl_init();
    2630    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    ));
    2736    curl_setopt($ch, CURLOPT_URL, $this->searchURI($upc));
    2837    $result = curl_exec($ch);
  • master-link/trunk/master-link.php

    r1896826 r2046394  
    66Author:       Greg Tangey
    77Author URI:   http://ignite.digitalignition.net/
    8 Version:      0.2.6
     8Version:      0.3.0
    99*/
    1010
     
    160160        "image" => "music-google_play.svg",
    161161        "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",
    162170      ),
    163171      "other" => array(
     
    367375          $key = "master_link_upc";
    368376          $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
    369382          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);
    373387          }
    374388          update_post_meta( $post_id, $key, $val );
     
    392406
    393407    function updateItunesAndAppleMusic($post_id,$upc) {
    394       if($itunes = $this->findItunes($upc)) {
     408      if($itunes = $this->findItunes($upc,$query)) {
    395409        update_post_meta($post_id,"master_link_plugin-itunes_link_id",$itunes['id']);
    396410        update_post_meta($post_id,"master_link_plugin-applemusic_link_id",$itunes['id']);
     
    400414
    401415    function updateDeezer($post_id,$upc) {
    402       if($deezer = $this->findDeezer($upc)) {
     416      if($deezer = $this->findDeezer($upc,$query)) {
    403417        update_post_meta($post_id,"master_link_plugin-deezer_link_id",$deezer['id']);
    404418        $this->updatePostImageIfImageNotExist($post_id, $deezer['cover']);
     
    407421
    408422    function updateSpotify($post_id,$upc) {
    409       if($spotify = $this->findSpotify($upc)) {
     423      if($spotify = $this->findSpotify($upc,$query)) {
    410424        update_post_meta($post_id,"master_link_plugin-spotify_link_id",$spotify['id']);
    411425        $this->updatePostImageIfImageNotExist($post_id, $spotify['cover']);
     
    413427    }
    414428
    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) {
    416436      require_once "finders/base.php";
    417437      require_once "finders/itunes.php";
    418438      $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) {
    423443      require_once "finders/base.php";
    424444      require_once "finders/deezer.php";
    425445      $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) {
    430450      require_once "finders/base.php";
    431451      require_once "finders/spotify.php";
    432452      $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);
    434461    }
    435462
  • master-link/trunk/readme.txt

    r1896826 r2046394  
    22Contributors: ruxton
    33Donate 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
     4Tags: links, app store, digital storefronts, deezer, itunes, google play, steam, amazon, soundcloud, youtube, tidal
    55Requires at least: 4.3.1
    6 Tested up to: 4.9.6
    7 Stable tag: 0.2.6
     6Tested up to: 5.1.0
     7Stable tag: 0.3.0
    88
    99Create links that link to multiple storefronts.  Great for music or software that is sold on many digital storefronts
     
    2222
    2323== 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
    2428
    2529= 0.2.6 =
  • master-link/trunk/scripts.js

    r1435539 r2046394  
    1 // Generated by CoffeeScript 1.10.0
     1// Generated by CoffeeScript 2.3.2
    22(function() {
    33  var embedSoundcloud, embedYouTubeVideo, setupBarcode;
     
    5656    $info = jQuery("#info");
    5757    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)
    5864    return jQuery(window).scroll(function() {
    5965      var newHeight, wScroll;
  • master-link/trunk/settings.php

    r1446205 r2046394  
    4848            register_setting('master_link_plugin', 'master_link_plugin-slug');
    4949            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>";
    50136        }
    51137
     
    117203        }
    118204
     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
    119215    }
    120216}
  • master-link/trunk/templates/metabox.php

    r1435539 r2046394  
    1212    <span class="add button-primary alignright"><?php _e('Add Link'); ?></span>
    1313    <table class="form-table striped sortable">
     14      <col width="15%"/>
     15      <col/>
     16      <col width="8%"/>
     17      <col width="10%"/>
    1418      <thead>
    1519        <tr>
  • master-link/trunk/templates/metabox_row.php

    r1420662 r2046394  
    11<tr class="master_link_row">
    22  <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]">
    44      <?php foreach($this->services as $services_service_id => $service) : ?>
    55        <?php $selected = ($services_service_id == $service_id); ?>
  • master-link/trunk/templates/settings.php

    r1420662 r2046394  
    88        <?php submit_button(); ?>
    99    </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
     14if(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?>
    1022</div>
Note: See TracChangeset for help on using the changeset viewer.