Plugin Directory

Changeset 1250130


Ignore:
Timestamp:
09/21/2015 08:52:09 AM (10 years ago)
Author:
hearthis
Message:

Update to 0.6.3 with major changes and updates.

Location:
hearthisat/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • hearthisat/trunk/hearthis-shortcode.php

    r902027 r1250130  
    33Plugin Name: hearthis.at
    44Plugin URI: http://wordpress.org/extend/plugins/hearthis-shortcode/
    5 Description: Converts hearthis WordPress shortcodes to a hearthis.at widget. Example: [hearthis]http://hearthis.at/shawne/shawne-stadtfest-chemnitz-31082013/[/hearthis]
    6 Version: 0.6.1
    7 Author: hearthis.at
    8 Author URI: http://hearthis.at
     5Description: Converts hearthis urls with Wordpress Shortcuts from within your content to a hearthis.at widget. Example: [hearthis]http://hearthis.at/crecs/shawne-stadtfest-chemnitz-31082013/[/hearthis]
     6Version: 0.6.3
     7Author: Andreas Jenke | SIEs
     8Author URI: http://so-ist.es
    99License: GPLv2
    1010
    11 Original version: Benedikt Gro&szlig; <[email protected]>
    12 
    1311*/
    1412
     13// Point to where you downloaded the phar
     14include(__DIR__.'/httpful.phar');
     15
     16/**
     17 * @link    hearthis.at
     18 * @category  Plugin URI: http://wordpress.org/extend/plugins/hearthis-shortcode/
     19 * @internal  Converts hearthis WordPress shortcodes to a hearthis.at widget. Example: [hearthis]http://hearthis.at/shawne/shawne-stadtfest-chemnitz-31082013/[/hearthis]
     20 * @version:  0.6.3
     21 * @author    Benedikt Gro&szlig; <[email protected]> | URL http://hearthis.at | upgraded by Andreas Jenke | SIEs
     22 * @license:  GPLv2
     23*/
     24
     25## Original version: Benedikt Gro&szlig; <[email protected]>
     26
     27/*[hearthis width="250"]https://hearthis.at/djforce/baesser-forcesicht-dnbmix/[/hearthis]
     28
     29[hearthis height="350"]https://hearthis.at/djforce/[/hearthis]
     30[hearthis height="350"]https://hearthis.at/crecs/set/tbase-feat-charlotte-haining-oscar-michael-unspoken-words-ep/[/hearthis]
     31[hearthis height="350"]http://hearthis.at/set/51-7/[/hearthis]*/
     32
    1533
    1634/* Register hearthis.at shortcode
    17    -------------------------------------------------------------------------- */
    18 
    19 add_shortcode("hearthis", "hearthis_shortcode");
    20 
    21 
    22 /**
    23  * hearthis.at shortcode handler
    24  * @param  {string|array}  $atts     The attributes passed to the shortcode like [hearthis attr1="value" /].
    25  *                                   Is an empty string when no arguments are given.
    26  * @param  {string}        $content  The content between non-self closing [hearthis]…[/hearthis] tags.
    27  * @return {string}                  Widget embed code HTML
    28  */
    29 function hearthis_shortcode($atts, $content = null) {
    30 
    31   // Custom shortcode options
    32   $shortcode_options = array_merge(array('url' => trim($content)), is_array($atts) ? $atts : array());
    33 
    34   // Turn shortcode option "param" (param=value&param2=value) into array
    35   $shortcode_params = array();
    36   if (isset($shortcode_options['params'])) {
    37     parse_str(html_entity_decode($shortcode_options['params']), $shortcode_params);
    38   }
    39   $shortcode_options['params'] = $shortcode_params;
    40 
    41   // User preference options
    42   $plugin_options = array_filter(array(
    43     'iframe' => hearthis_get_option('player_iframe', true),
    44     'width'  => hearthis_get_option('player_width'),
    45     'height' =>  hearthis_url_has_tracklist($shortcode_options['url']) ? hearthis_get_option('player_height_multi') : hearthis_get_option('player_height'),
    46     'params' => array_filter(array(
    47       'hcolor'         => hearthis_get_option('color'),
    48       'color'         => hearthis_get_option('color2'),
    49       'theme'   => hearthis_get_option('theme'),
    50       'style'   => hearthis_get_option('style'),
    51       'style_size'   => hearthis_get_option('style_size'),
    52       'style_space'   => hearthis_get_option('style_space'),
    53     )),
    54   ));
    55   // Needs to be an array
    56   if (!isset($plugin_options['params'])) { $plugin_options['params'] = array(); }
    57 
    58   // plugin options < shortcode options
    59   $options = array_merge(
    60     $plugin_options,
    61     $shortcode_options
    62   );
    63 
    64   // plugin params < shortcode params
    65   $options['params'] = array_merge(
    66     $plugin_options['params'],
    67     $shortcode_options['params']
    68   );
    69 
    70   // The "url" option is required
    71   if (!isset($options['url'])) {
    72     return '';
    73   } else {
    74     $options['url'] = trim($options['url']);
    75   }
    76 
    77   // Both "width" and "height" need to be integers
    78   if (isset($options['width']) && !preg_match('/^\d+$/', $options['width'])) {
    79     // set to 0 so oEmbed will use the default 100% and WordPress themes will leave it alone
    80     $options['width'] = 0;
    81   }
    82   if (isset($options['height']) && !preg_match('/^\d+$/', $options['height'])) { unset($options['height']); }
    83 
    84 
    85   return hearthis_iframe_widget($options);
    86  
     35-------------------------------------------------------------------------- */
     36
     37  add_shortcode("hearthis", "hearthis_shortcode");
     38
     39  /**
     40   * hearthis.at shortcode handler
     41   * @param  {string|array}  $atts     The attributes passed to the shortcode like [hearthis attr1="value" /].
     42   *                                   Is an empty string when no arguments are given.
     43   * @param  {string}        $content  The content between non-self closing [hearthis]…[/hearthis] tags.
     44   * @return {string}                  Widget embed code HTML
     45   */
     46  function hearthis_shortcode($atts, $content = null)
     47  {
     48
     49    // Custom shortcode options
     50    $shortcode_options = array_merge(
     51      array('url' => trim($content)),
     52      is_array($atts) ? $atts : array()
     53    );
     54
     55    // Turn shortcode option "param" (param=value&param2=value) into array
     56    $shortcode_params = array();
     57    if (isset($shortcode_options['params']))
     58      parse_str(html_entity_decode($shortcode_options['params']), $shortcode_params);
     59
     60    $shortcode_options['params'] = $shortcode_params;
     61
     62    if(hearthis_url_is_type($shortcode_options['url']) === 'set')
     63      $height = get_option('player_height',450);
     64    else if (hearthis_url_is_type($shortcode_options['url']) === 'profile')
     65      $height = get_option('player_height',350);
     66    else if (hearthis_url_is_type($shortcode_options['url']) === 'track')
     67      $height = get_option('player_height',145);
     68    // else
     69    //   $height = hearthis_get_option('player_height',145);
     70
     71
     72    // plugins default options
     73    $plugin_options = array(
     74      'iframe' => get_option('hearthis_player_iframe', true),
     75      'width' => get_option('hearthis_player_width'),
     76      'height' => ($height !== '' ) ? $height : 145,
     77      'color' => get_option('hearthis_color'),
     78      'hcolor' => get_option('hearthis_color2'),
     79      'cover' => get_option('hearthis_cover', 0),
     80      'autoplay' => get_option('hearthis_autoplay', 0),
     81      'style' => get_option('hearthis_style', 1),
     82      'theme' => get_option('hearthis_theme','transparent'),
     83      'waveform' => get_option('hearthis_waveform'),
     84      'background' => get_option('hearthis_background'),
     85      'block_space' => get_option('hearthis_digitized_space', 1),
     86      'block_size' => get_option('hearthis_digitized_size', 2)
     87      );
     88
     89    #echo '<pre>'.print_r(hearthis_url_is_type($shortcode_options['url']) ,true).'</pre>';   
     90
     91    // get shortcode options
     92    $options['params'] = array_merge(
     93      $plugin_options,
     94      hearthis_code_params()
     95    );
     96      // plugin params < options params
     97    $options = array_merge(
     98      $plugin_options,
     99      $shortcode_options
     100      );
     101    if(hearthis_url_is_type($shortcode_options['url']) === 'track' && $options['background'] == 1)
     102    {
     103      $options['height'] = 400;
     104    }
     105
     106    if (!isset($options['url']))
     107      return '';
     108    else
     109      $options['url'] = trim($options['url']);
     110
     111    if(isset($options['width']) && ! hearthis_is_integer($options['width']))
     112      $options['width'] = '100%';
     113
     114    return hearthis_iframe_widget($options);
     115
     116  }
     117
     118
     119  function hearthis_code_params()
     120  {
     121    $opts = array(
     122      'width' => hearthis_get_option('player_width'),
     123      'color' => hearthis_get_option('hearthis_color'),
     124      'hcolor' => hearthis_get_option('hearthis_color2'),
     125      'cover' => hearthis_get_option('cover'),
     126      'autoplay' => hearthis_get_option('autoplay'),
     127      'style' => hearthis_get_option('style'),
     128      'theme' => hearthis_get_option('theme'),
     129      'waveform' => hearthis_get_option('waveform',NULL),
     130      'background' => hearthis_get_option('background',NULL),
     131      'block_space' => hearthis_get_option('digitized_space'),
     132      'block_size' => hearthis_get_option('digitized_size'),
     133      'theme'  => hearthis_get_option('theme'),
     134      'style'  => hearthis_get_option('style'),
     135      'liststyle'  => (hearthis_get_option('liststyle') === 'single') ?  'single' : NULL,
     136    );
     137    foreach ($opts as $k => $value)
     138      $opts[$k] = $value;
     139
     140    return $opts;
     141  }
     142
     143  function hearthis_is_integer($input)
     144  {
     145    return preg_match('/^\d+$/', $input);
     146  }
     147
     148  function hearthis_iframe_url($options,$info)
     149  {
     150    $url = 'https://hearthis.at';
     151
     152    if($info['type'] === 'set' && !isset($options['liststyle']) )
     153    {
     154      $url .= esc_attr($info['player_url']).'embed/?hcolor='.hearthis_clear_color(hearthis_get_option('color2')).'&color='.hearthis_clear_color(hearthis_get_option('color'));
     155 
     156    }
     157    if($info['type'] === 'set' && isset($options['liststyle']) &&  $options['liststyle'] === 'single' )
     158    { 
     159     
     160      foreach ($info['setlist'] as $tune)
     161      {
     162        # code...
     163          $href = 'https://hearthis.at/embed/'.esc_attr($tune['tracks']).'/'.hearthis_get_option('theme').'/?';
     164          $href .='hcolor='.hearthis_clear_color(hearthis_get_option('color2')).
     165          '&color='.hearthis_clear_color(hearthis_get_option('color')).
     166          '&style='.hearthis_get_option('style').
     167          '&block_space='.hearthis_get_option('digitized_space').
     168          '&block_size='.hearthis_get_option('digitized_size').
     169          '&background='.hearthis_get_option('background',get_option('hearthis_background', 0)).
     170          '&waveform='.hearthis_get_option('waveform').
     171          '&cover='.hearthis_get_option('cover').
     172          '&autoplay='.hearthis_get_option('autoplay');
     173          $u[] = $href;
     174      }
     175      $url = $u;
     176 
     177    }
     178
     179    if($info['type'] === 'track')
     180    {
     181      $url = 'https://hearthis.at/embed/'.esc_attr($info['track_id']).'/'.hearthis_get_option('theme').'/?';
     182      $url .='hcolor='.hearthis_clear_color(hearthis_get_option('color2')).
     183      '&color='.hearthis_clear_color(hearthis_get_option('color')).
     184      '&style='.hearthis_get_option('style').
     185      '&block_space='.hearthis_get_option('digitized_space').
     186      '&block_size='.hearthis_get_option('digitized_size').
     187      '&background='.hearthis_get_option('background',get_option('hearthis_background', 0)).
     188      '&waveform='.hearthis_get_option('waveform').
     189      '&cover='.hearthis_get_option('cover').
     190      '&autoplay='.hearthis_get_option('autoplay');
     191    }
     192
     193    if($info['type'] === 'profile')
     194      $url = $options['url'].'embed/?hcolor='.hearthis_clear_color(hearthis_get_option('color2')).'&color='.hearthis_clear_color(hearthis_get_option('color'));
     195
     196    return $url;
     197
     198  }
     199
     200
     201  /**
     202   * Plugin options getter
     203   * @param  {string|array}  $option   Option name
     204   * @param  {mixed}         $default  Default value
     205   * @return {mixed}                   Option value
     206   */
     207  function hearthis_get_option($option, $default = '')
     208  {
     209    $value = get_option('hearthis_' . $option);
     210    return $value === '' ? $default : $value;
     211  }
     212
     213
     214  /**
     215   * Decide if a url has a tracklist
     216   * @param  {string}   $url
     217   * @return {boolean}
     218   */
     219  function hearthis_url_is_type($url)
     220  {
     221
     222    $test = hearthis_get_type_from_url($url);
     223    if(isset($test['type']))
     224      return $test['type'];
     225  }
     226
     227
     228  /**
     229   * Decide if a url has a tracklist
     230   * @param  {string}   $url
     231   * @return {boolean}
     232   */
     233  function hearthis_bypass_set_url($url)
     234  {
     235
     236    $parts = parse_url($url);
     237    $url_split = explode('/', $parts['path']);
     238
     239    if($url_split[2] === 'set')
     240    {
     241      $l = get_headers($url.'embed/',true);
     242      if(isset($l['Location']))
     243      {
     244        $url = str_replace('embed/', '', $l['Location']);
     245      }
     246      unset($l);
     247    }
     248    return hearthis_get_type_from_url($url);
     249  }
     250
     251  /**
     252   * Decide if a url has a tracklist
     253   * @param  {string}   $url
     254   * @return {boolean}
     255   */
     256  function hearthis_get_type_from_url($url)
     257  {
     258
     259    $parts = parse_url($url);
     260    $url_split = explode('/', $parts['path']);
     261    $info = array(
     262      'type' => 'track',
     263      'user' => FALSE,
     264      'player_url' => $parts['path'],
     265      'setlist' => FALSE,
     266      'track_id' => FALSE
     267      );
     268
     269    unset($url_split[count($url_split)-1]);
     270
     271    if(count($url_split) === 2)
     272    {
     273      $info['type'] = 'profile';
     274      $info['user'] = $url_split[1];
     275    }
     276
     277
     278    if(count($url_split) > 2)
     279    {
     280      $response = \Httpful\Request::get('http://api-v2.hearthis.at'.$parts['path'])->send();
     281      $info['user'] = $response->body->user->permalink;
     282      $info['track_id'] = $response->body->id;
     283
     284      for ($i=0; $i < count($url_split); $i++)
     285      {
     286        if(strtolower($url_split[$i]) === 'set')
     287          $info['type'] = 'set';
     288
     289        if( $i < 2 && $url_split[$i] !== 'set')
     290          $info['user'] = $url_split[$i];
     291      }
     292
     293      if (count($response->body) > 1 )
     294      {
     295        for ($j=0; $j < count($response->body); $j++)
     296        {
     297          if($info['type'] === 'set')
     298          {
     299            $info['setlist'][] = array(
     300              'users' => $response->body[$j]->user->permalink,
     301              'tracks' => $response->body[$j]->id
     302              );
     303
     304          # unset($info['track_id']); //  = FALSE;
     305
     306            if( empty($info['user']) )
     307            unset($info['user']); //  = FALSE;
     308
     309        }
     310        // $user_ids[] = $response->body[$j]->user->permalink;
     311        // $track_ids[] = $response->body[$j]->id;
     312      }
     313    }
     314  }
     315
     316  return $info;
     317  }
     318
     319
     320  /**
     321   * Iframe widget embed code
     322   * @param  {array}   $options  Parameters
     323   * @return {string}            Iframe embed code
     324   */
     325  function hearthis_iframe_widget($options)
     326  {
     327    $url = '';
     328    $urlSource = parse_url($options['url']);
     329
     330    $width = $options['width'];
     331    $height = $options['height'];
     332    $return = array();
     333   
     334  $infos = hearthis_bypass_set_url($options['url']);   
     335  $url = hearthis_iframe_url($options,$infos);
     336
     337    if(isset($options['liststyle']) && $options['liststyle'] === 'single')
     338    {
     339         foreach($url as $href)
     340         {
     341              $return['SL'][] = sprintf('<div><iframe class="hearthis-iframe-widget" width="%s" height="%s" scrolling="no" frameborder="no" src="%s" allowtransparency></iframe></div>', $width, '145', $href);
     342         }
     343    }
     344    else {
     345        $return['SL'][] = sprintf('<iframe class="hearthis-iframe-widget" width="%s" height="%s" scrolling="no" frameborder="no" src="%s" allowtransparency></iframe>', $width, $height, $url);
     346    }
     347
     348
     349    if(isset($return['SL']))
     350    {
     351      for ($i=0; $i < count($return['SL']); $i++)
     352      {
     353        $_return .= $return['SL'][$i];
     354      }
     355      return $_return;
     356    }
     357  }
     358
     359
     360
     361
     362  /* Settings
     363  -------------------------------------------------------------------------- */
     364
     365  /* Add settings link on plugin page */
     366  add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'hearthis_settings_link');
     367  function hearthis_settings_link($links)
     368  {
     369    $settings_link = '<a href="options-general.php?page=hearthis-shortcode">Settings</a>';
     370    array_unshift($links, $settings_link);
     371    return $links;
     372  }
     373
     374
     375  /* Add admin menu */
     376  add_action('admin_menu', 'hearthis_shortcode_options_menu');
     377  function hearthis_shortcode_options_menu()
     378  { if( is_admin() )
     379    {
     380      add_options_page('hearthis.at Options', 'hearthis.at', 'manage_options', 'hearthis-shortcode', 'hearthis_shortcode_options');
     381      add_action('admin_init', 'register_hearthis_settings');
     382    }
     383  }
     384
     385
     386  function register_hearthis_settings()
     387  {
     388
     389    register_setting('hearthis-settings', 'hearthis_liststyle');
     390    register_setting('hearthis-settings', 'hearthis_player_iframe');
     391    register_setting('hearthis-settings', 'hearthis_player_width');
     392    register_setting('hearthis-settings', 'hearthis_player_height');
     393    register_setting('hearthis-settings', 'hearthis_player_profile_height');
     394    register_setting('hearthis-settings', 'hearthis_player_height_multi');
     395    register_setting('hearthis-settings', 'hearthis_color');
     396    register_setting('hearthis-settings', 'hearthis_color2');
     397    register_setting('hearthis-settings', 'hearthis_cover');
     398    register_setting('hearthis-settings', 'hearthis_autoplay');
     399    register_setting('hearthis-settings', 'hearthis_style');
     400    register_setting('hearthis-settings', 'hearthis_theme');
     401    register_setting('hearthis-settings', 'hearthis_waveform');
     402    register_setting('hearthis-settings', 'hearthis_background');
     403    register_setting('hearthis-settings', 'hearthis_digitized_space');
     404    register_setting('hearthis-settings', 'hearthis_digitized_size');
     405
     406  }
     407
     408  /**
     409   * Function that will check if value is a valid HEX color.
     410   */
     411  function hearthis_check_color( $value ) {
     412
     413    if ( preg_match( '/^#[a-f0-9]{6}$/i', $value ) ) {
     414      return true;
     415    }
     416
     417    return false;
     418  }
     419  /**
     420   * Function that will check if value is a valid HEX color.
     421   */
     422  function hearthis_clear_color( $value ) {
     423
     424    if(hearthis_check_color($value))
     425    {
     426      $value = str_replace('#', '', $value);
     427    }
     428
     429    return $value;
     430  }
     431
     432
     433  add_action( 'admin_enqueue_scripts', 'hearthis_add_color_picker' );
     434  function hearthis_add_color_picker( $hook )
     435  {
     436    if( is_admin() )
     437    {
     438      // Add the color picker css file
     439      wp_enqueue_style( 'wp-color-picker' );
     440
     441      // Include our custom jQuery file with WordPress Color Picker dependency
     442      wp_enqueue_script( 'wp-color-picker' );
     443    }
     444  }
     445
     446
     447  function hearthis_shortcode_options()
     448  {
     449    if (!current_user_can('manage_options'))
     450      wp_die( __('You do not have sufficient permissions to access this page.') );
     451    ?>
     452    <div class="wrap">
     453      <h2>hearthis.at Default Settings</h2>
     454      <p>You can always override these settings with your shortcode for each preference. Your shortcode will always overrides these defaults individually. Please note that not every settting does affect. The settings depends on your hearthis.at url and if its a track, playlist or profile link.</p>
     455
     456      <form method="post" action="options.php">
     457      <?php settings_fields( 'hearthis-settings' ); ?>
     458        <table class="form-table">
     459          <tr valign="top">
     460            <th scope="row">Current Default 'params'</th>
     461            <td><?php  echo http_build_query(array_filter(array(
     462              'width'            => get_option('hearthis_player_width'),
     463              'height'           => get_option('hearthis_player_height'),
     464              'profile_height'   => get_option('hearthis_player_profile_height'),
     465              'multi_height'     => get_option('hearthis_player_height_multi'),
     466              'color2'           => get_option('hearthis_color2'),
     467              'color'            => get_option('hearthis_color'),
     468              'cover'            => get_option('hearthis_cover'),
     469              'autoplay'         => get_option('hearthis_autoplay'),
     470              'style'            => get_option('hearthis_style'),
     471              'theme'            => get_option('hearthis_theme'),
     472              'waveform'         => get_option('hearthis_waveform'),
     473              'background'       => get_option('hearthis_background'),
     474              'block_space'      => get_option('hearthis_digitized_space'), // style_size
     475              'block_size'       => get_option('hearthis_digitized_size'), // style_space
     476              ))); ?>
     477            </td>
     478          </tr>
     479
     480          <tr valign="top">
     481            <th scope="row">Player default width</th>
     482            <td><input type="text" name="hearthis_player_width" value="<?php echo get_option('hearthis_player_width'); ?>"> (px or %)<br />
     483              Leave blank to use the default.</td>
     484            </td>
     485          </tr>
     486          <tr valign="top">
     487            <th scope="row">Player default height (single track)</th>
     488            <td>
     489              <input type="text" name="hearthis_player_height" id="hearthis_player_height" value="<?php echo get_option('hearthis_player_height'); ?>"> (px or %)<br />
     490              Leave blank to use the default.</td>
     491            </td>
     492          </tr>
     493          <tr valign="top">
     494            <th scope="row">Player Height for Profile</th>
     495            <td><input type="text" name="hearthis_player_profile_height" id="hearthis_player_profile_height" value="<?php echo get_option('hearthis_player_profile_height'); ?>">  (px or %)<br />
     496              Leave blank to use the default.</td>
     497            </td>
     498          </tr>
     499          <tr valign="top">
     500            <th scope="row">Player Height for Sets</th>
     501            <td><input type="text" name="hearthis_player_height_multi" id="hearthis_player_height_multi" value="<?php echo get_option('hearthis_player_height_multi'); ?>"> (px or %)<br />
     502              Leave blank to use the default.</td>
     503            </td>
     504          </tr>
     505          <tr valign="top">
     506            <th scope="row">Color Waveform</th>
     507            <td><input type="text" id="hearthis_color2" name="hearthis_color2" value="<?php echo get_option('hearthis_color2'); ?>">
     508              Defines the default waveform color.</td>
     509            </td>
     510          </tr>
     511          <tr valign="top">
     512            <th scope="row">Color Play button </th>
     513            <td><input type="text" id="hearthis_color" name="hearthis_color" value="<?php echo get_option('hearthis_color'); ?>">
     514              Defines the color of the play button and the waveform from the passed time.</td>
     515            </td>
     516          </tr>
     517          <tr valign="top">
     518            <th scope="row">Show cover image</th>
     519            <td>
     520              <input type="checkbox" name="hearthis_cover" id="hearthis_cover" value="<?php echo get_option('hearthis_cover');?>"<?php if(get_option('hearthis_cover') == 1) echo ' checked="checked"'; ?>>
     521              <label for="hearthis_cover" style="margin-right: 1em;">show cover, off/on</label><br /> Defines if the player should show the cover image.</td>
     522            </td>
     523          </tr>
     524          <tr valign="top">
     525            <th scope="row">Show waveform</th>
     526            <td>
     527              <input type="checkbox" name="hearthis_waveform" id="hearthis_waveform" value="<?php echo get_option('hearthis_waveform');?>"<?php if(get_option('hearthis_waveform') == 1) echo ' checked="checked"'; ?>>
     528              <label for="hearthis_waveform" style="margin-right: 1em;">hide waveform, off/on</label><br /> Defines if the player will show the waveform image.
     529            </td>
     530          </td>
     531        </tr>
     532
     533        <tr valign="top">
     534          <th scope="row">Show background image</th>
     535          <td>
     536            <input type="checkbox" name="hearthis_background" id="hearthis_background" value="<?php echo get_option('hearthis_background');?>"<?php if(get_option('hearthis_background') == 1) echo ' checked="checked"'; ?>>
     537            <label for="hearthis_background" style="margin-right: 1em;">hide background image (if set), off/on</label><br /> Defines if the player will show the background image if it set.
     538          </td>
     539        </tr>
     540
     541        <tr valign="top">
     542          <th scope="row">Start Autoplay</th>
     543          <td>
     544            <input type="checkbox" name="hearthis_autoplay" id="hearthis_autoplay" value="<?php echo get_option('hearthis_autoplay');?>" <?php if(get_option('hearthis_autoplay') == 1) echo ' checked="checked"'; ?>>
     545            <label for="hearthis_autoplay" style="margin-right: 1em;">autoplay, off/on</label><br /> Defines if the player will start autoplay after loading.</td>
     546          </td>
     547        </tr>
     548      <tr valign="top">
     549      <th scope="row">Waveform Style</th>
     550        <td>         
     551          <select id="hearthis_style" name="hearthis_style">
     552            <option value="1" <?php if (strtolower(get_option('hearthis_style')) == '1') echo 'selected="selected"'; ?>>Waveform Style: Soft</option>
     553            <option value="2" <?php if (strtolower(get_option('hearthis_style')) == '2') echo 'selected="selected"'; ?>>Waveform Style: Digitized</option>
     554          </select>
     555
     556          <div id="template-2" style="display: none;">
     557            <div style="float: left; width: 48%;">
     558              <div style="float: left; margin-top: 9px;">Block Size</div>
     559              <input id="hearthis_digitized_size" name="hearthis_digitized_size" type="range" min="1" max="10" step="1" value="<?php echo (int) get_option('hearthis_digitized_size','2'); ?>" style="float: left; margin-right: 15px;" />                       
     560
     561            </div>
     562            <div style="float: right; width: 48%;">
     563              <div style="float: left; margin-top: 9px;">Block Space</div>
     564              <input id="hearthis_digitized_space" type="range" name="hearthis_digitized_space" min="1" max="10" step="1" value="<?php echo (int) get_option('hearthis_digitized_space','1'); ?>" style="float: left; margin-right: 15px;" />
     565            </div>
     566          </div>
     567          <script>
     568
     569          (function( $ ) {
     570
     571            $("#hearthis_style").change(function()
     572            {
     573              if($(this).val() == 2)
     574              {
     575                $("#template-2").slideDown(500);
     576                style = 2;
     577              }
     578              else
     579              {
     580                $("#template-2").slideUp(500);
     581                style = 1;
     582              }
     583            }); 
     584
     585            var waveform = 0, background = 0;
     586
     587            var chgFct = function(elm, olm, b) {
     588              var f = (b == '') ? false : true;
     589              var el = document.getElementById(elm);
     590              var o = document.getElementById(olm);
     591
     592              if (el.checked == true ) {
     593                el.value = 1;
     594                if(el.id == 'hearthis_waveform')
     595                  waveform = 1;
     596                o.value = 0;
     597                o.checked = false;
     598
     599                $(o).prop("disabled", 'disabled');
     600
     601              } else {
     602
     603                if(el.id == 'hearthis_background')
     604                  background = 1;
     605                el.value = 0;
     606                el.checked = false
     607                  // o.checked = false;
     608                  $(o).prop("disabled", false);
     609              }
     610              changeEmbedPlayer();
     611            };
     612
     613            $("#hearthis_background").change(function() {
     614              chgFct('hearthis_background',"hearthis_waveform",false);
     615            });
     616
     617            $("#hearthis_waveform").change(function() {
     618              chgFct('hearthis_waveform',"hearthis_background",false);
     619            });
     620
     621            $(window).on('load', function()
     622            {
     623              chgFct('hearthis_background',"hearthis_waveform", true);
     624              chgFct('hearthis_waveform',"hearthis_background", true);
     625            });
     626
     627            $("#hearthis_autoplay").change(function() {
     628              if (this.checked)
     629                this.value = 1;
     630              else
     631                this.value = 0;
     632            });
     633
     634            $("#hearthis_cover").change(function() {
     635              if (this.checked) {
     636                this.value = 1;
     637              } else {
     638                this.value = 0;
     639              }
     640            });
     641               
     642            /* do it later*/
     643            /* $("#hearthis_css").keyup(function() {
     644
     645              css = jQuery(this).val();
     646              css = css.replace(/(<([^>]+)>)/ig,"");
     647                css = css.replace(" ","+");
     648
     649              delay(function(){
     650                  if(css.length > 2) {
     651                    changeEmbedPlayer();
     652                  }
     653                }, 500 );
     654            });*/
     655
     656
     657            $("#hearthis_digitized_size").change(function() {
     658              this.value = $(this).val();
     659            });
     660
     661
     662            $("#hearthis_digitized_space").change(function() {
     663              this.value = $(this).val();
     664            });
     665
     666            function changeEmbedPlayer() { 
     667
     668              $("#hearthis_player_height").val('145');
     669
     670              if(waveform == 1) {
     671                $("#hearthis_player_height").val('145');
     672              }
     673              if(background == 1) {
     674                $("#hearthis_player_height").val('400');
     675              }
     676              if(background == 0) {
     677                $("#hearthis_player_height").val('145');
     678              }
     679              if(waveform == 0 && background == 0) {
     680                $("#hearthis_player_height").val('145');
     681              }
     682            }
     683
     684            $(function() {
     685              $('#hearthis_color,#hearthis_color2').wpColorPicker();
     686            });
     687
     688
     689            })( jQuery );
     690
     691          </script>
     692          </td>
     693        </tr>
     694        <tr valign="top">
     695          <th scope="row">Theme Color (Tracks Only)</th>
     696          <td>         
     697            <input type="radio" id="hearthis_theme_color_light"  name="hearthis_theme" value="transparent"  <?php if (strtolower(get_option('hearthis_theme')) === 'transparent')  echo 'checked'; ?> />
     698            <label for="hearthis_theme_color_light"  style="margin-right: 1em;">Light</label>
     699            <input type="radio" id="hearthis_theme_color_dark" name="hearthis_theme" value="transparent_black" <?php if (strtolower(get_option('hearthis_theme')) === 'transparent_black') echo 'checked'; ?> />
     700            <label for="hearthis_theme_color_dark" style="margin-right: 1em;">Dark</label>
     701          </td>
     702        </tr>
     703      </table>
     704      <p class="submit">
     705        <input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?>" />
     706      </p>
     707    </form>
     708  </div>
     709  <?php
    87710}
    88 
    89 /**
    90  * Plugin options getter
    91  * @param  {string|array}  $option   Option name
    92  * @param  {mixed}         $default  Default value
    93  * @return {mixed}                   Option value
    94  */
    95 function hearthis_get_option($option, $default = false) {
    96   $value = get_option('hearthis_' . $option);
    97   return $value === '' ? $default : $value;
    98 }
    99 
    100 /**
    101  * Booleanize a value
    102  * @param  {boolean|string}  $value
    103  * @return {boolean}
    104  */
    105 function hearthis_booleanize($value) {
    106   return is_bool($value) ? $value : $value === 'true' ? true : false;
    107 }
    108 
    109 /**
    110  * Decide if a url has a tracklist
    111  * @param  {string}   $url
    112  * @return {boolean}
    113  */
    114 function hearthis_url_has_tracklist($url) {
    115    
    116   $hearthis_url_has_tracklist = false;
    117  
    118     $count = 0;
    119     $url_split = explode('/', $url);
    120     foreach ($url_split as &$countval) {
    121         if(!empty($countval)) {
    122             $count++;
    123         }
    124     }
    125  
    126   if(preg_match('/^(.+?)\/(set)\/(.+?)$/', $url) || ($count == 3)) {
    127     $hearthis_url_has_tracklist = true;   
    128      
    129   }
    130    
    131   return $hearthis_url_has_tracklist;
    132 }
    133 
    134 
    135 /**
    136  * Iframe widget embed code
    137  * @param  {array}   $options  Parameters
    138  * @return {string}            Iframe embed code
    139  */
    140 function hearthis_iframe_widget($options) {
    141 
    142     $urlSource = parse_url($options['url']);
    143            
    144     $count = 0;
    145     $url_split = explode('/', $options['url']);
    146     foreach ($url_split as &$countval) {
    147         if(!empty($countval)) {
    148             $count++;
    149         }
    150     }
    151    
    152     $hearthis_url_has_tracklist = false;
    153        
    154     if(preg_match('/^(.+?)\/(set)\/(.+?)$/', $options['url']) || ($count == 3)) {     
    155         $hearthis_url_has_tracklist = true;
    156         $url = $options['url'] . 'embed/' . (!empty($options['params']['hcolor']) ? '?hcolor=' . $options['params']['hcolor'] : '');
    157        
    158     } else {
    159         if(isInteger(substr($urlSource['path'],1,-1))) {
    160               $trackID = substr($urlSource['path'],1,-1);
    161         } else {
    162               $apiUrl= 'http://api.hearthis.at' . $urlSource['path'];
    163               $cc = new cURL();
    164               $apiContent = $cc->get($apiUrl);
    165               $apiResult = @json_decode($apiContent, true);
    166               $trackID = $apiResult['data']['id'];
    167         }
    168    
    169        
    170         // Merge in "url" value
    171         $options['params'] = array_merge(array(
    172             'url' => $options['url']
    173         ), $options['params']);
    174        
    175         // Build URL
    176         $url = '//hearthis.at/embed/' . $trackID . '/' . $options['params']['theme'] . '/?style=' . $options['params']['style'] . '' . (!empty($options['params']['style_size']) ? '&block_size=' . $options['params']['style_size'] : '') . '' . (!empty($options['params']['style_space']) ? '&block_space=' . $options['params']['style_space'] : '') . '' . (!empty($options['params']['hcolor']) ? '&hcolor=' . $options['params']['hcolor'] : '') . '' . (!empty($options['params']['color']) ? '&color=' . $options['params']['color'] : '') . '';
    177        
    178     }
    179    
    180    
    181    
    182     // Set default width if not defined
    183     $width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%';
    184     // Set default height if not defined
    185     $height = isset($options['height']) && $options['height'] !== 0 ? $options['height'] : ($hearthis_url_has_tracklist ? '450' : '150');
    186    
    187     return sprintf('<iframe class="hearthis-iframe-widget" width="%s" height="%s" scrolling="no" frameborder="no" src="%s" allowtransparency></iframe>', $width, $height, $url);
    188 }
    189 
    190 /* Settings
    191    -------------------------------------------------------------------------- */
    192 
    193 /* Add settings link on plugin page */
    194 add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'hearthis_settings_link');
    195 
    196 function hearthis_settings_link($links) {
    197   $settings_link = '<a href="options-general.php?page=hearthis-shortcode">Settings</a>';
    198   array_unshift($links, $settings_link);
    199   return $links;
    200 }
    201 
    202 /* Add admin menu */
    203 add_action('admin_menu', 'hearthis_shortcode_options_menu');
    204 function hearthis_shortcode_options_menu() {
    205   add_options_page('hearthis.at Options', 'hearthis.at', 'manage_options', 'hearthis-shortcode', 'hearthis_shortcode_options');
    206   add_action('admin_init', 'register_hearthis_settings');
    207 }
    208 
    209 function register_hearthis_settings() {
    210   register_setting('hearthis-settings', 'hearthis_player_height');
    211   register_setting('hearthis-settings', 'hearthis_player_height_multi');
    212   register_setting('hearthis-settings', 'hearthis_player_width ');
    213   register_setting('hearthis-settings', 'hearthis_color');
    214   register_setting('hearthis-settings', 'hearthis_color2');
    215   register_setting('hearthis-settings', 'hearthis_theme');
    216   register_setting('hearthis-settings', 'hearthis_style');
    217   register_setting('hearthis-settings', 'hearthis_style_size');
    218   register_setting('hearthis-settings', 'hearthis_style_space');
    219 }
    220 
    221 function isInteger($input){
    222     return(ctype_digit(strval($input)));
    223 }
    224 
    225 
    226 function hearthis_shortcode_options() {
    227   if (!current_user_can('manage_options')) {
    228     wp_die( __('You do not have sufficient permissions to access this page.') );
    229   }
    230 ?>
    231 <div class="wrap">
    232   <h2>hearthis.at Default Settings</h2>
    233   <p>You can always override these settings on a per-shortcode basis. Setting the 'params' attribute in a shortcode overrides these defaults individually.</p>
    234 
    235   <form method="post" action="options.php">
    236     <?php settings_fields( 'hearthis-settings' ); ?>
    237     <table class="form-table">
    238 
    239       <tr valign="top">
    240         <th scope="row">Player Height for Sets</th>
    241         <td>
    242           <input type="text" name="hearthis_player_height_multi" value="<?php echo get_option('hearthis_player_height_multi'); ?>" /> (no unit, or %)<br />
    243           Leave blank to use the default.
    244         </td>
    245       </tr>
    246 
    247       <tr valign="top">
    248         <th scope="row">Player Width</th>
    249         <td>
    250           <input type="text" name="hearthis_player_width" value="<?php echo get_option('hearthis_player_width'); ?>" /> (no unit, or %)<br />
    251           Leave blank to use the default.
    252         </td>
    253       </tr>
    254 
    255       <tr valign="top">
    256         <th scope="row">Current Default 'params'</th>
    257         <td>
    258           <?php echo http_build_query(array_filter(array(
    259             'hcolor'         => get_option('hearthis_color'),
    260             'color'         => get_option('hearthis_color2'),
    261             'style'         => get_option('hearthis_style'),
    262             'style_size'         => get_option('hearthis_style_size'),
    263             'style_space'         => get_option('hearthis_style_space'),
    264             'theme'   => get_option('hearthis_theme'),
    265           ))) ?>
    266         </td>
    267       </tr>
    268 
    269       <tr valign="top">
    270         <th scope="row">Waveform Default Color</th>
    271         <td>
    272           <input type="text" name="hearthis_color2" value="<?php echo get_option('hearthis_color2'); ?>" /> (color hex code e.g. ff6699)<br />
    273           Defines the default waveform color.
    274         </td>
    275       </tr>
    276    
    277       <tr valign="top">
    278         <th scope="row">Waveform Highlight Color</th>
    279         <td>
    280           <input type="text" name="hearthis_color" value="<?php echo get_option('hearthis_color'); ?>" /> (color hex code e.g. ff6699)<br />
    281           Defines the color to paint the play button, waveform and selections.
    282         </td>
    283       </tr>
    284      
    285 
    286       <tr valign="top">
    287         <th scope="row">Theme Color (Tracks Only)</th>
    288         <td>         
    289           <input type="radio" id="hearthis_theme_color_light"  name="hearthis_theme" value="transparent"  <?php if (strtolower(get_option('hearthis_theme')) === 'transparent')  echo 'checked'; ?> />
    290           <label for="hearthis_theme_color_light"  style="margin-right: 1em;">Light</label>
    291           <input type="radio" id="hearthis_theme_color_dark" name="hearthis_theme" value="transparent_black" <?php if (strtolower(get_option('hearthis_theme')) === 'transparent_black') echo 'checked'; ?> />
    292           <label for="hearthis_theme_color_dark" style="margin-right: 1em;">Dark</label>
    293          
    294         </td>
    295       </tr>
    296      
    297       <tr valign="top">
    298         <th scope="row">Waveform Style</th>
    299         <td>         
    300           <select id="track-share-embed-style"  name="hearthis_style">
    301                 <option value="1" <?php if (strtolower(get_option('hearthis_style')) === '1') echo 'checked'; ?>>Waveform Style: Soft</option>
    302                 <option value="2" <?php if (strtolower(get_option('hearthis_style')) === '2') echo 'checked'; ?>>Waveform Style: Digitized</option>
    303             </select>
    304            
    305             <div id="template-2" style="display: none;">
    306                 <div style="float: left; width: 48%;">
    307                     <div style="float: left; margin-top: 9px;">Block Size</div>
    308                     <input id="track-share-embed-style2-block-size" name="hearthis_digitized_size" type="range" min="1" max="20" step="1" value="5" style="float: left; margin-right: 15px;" />                       
    309                    
    310                 </div>
    311                 <div style="float: right; width: 48%;">
    312                     <div style="float: left; margin-top: 9px;">Block Space</div>
    313                      <input id="track-share-embed-style2-block-space" type="range" name="hearthis_digitized_space" min="0" max="10" step="1" value="1" style="float: left; margin-right: 15px;" />
    314                 </div>
    315             </div>
    316             <script>
    317            
    318             $("#track-share-embed-style").change(function() {
    319                 if(jQuery(this).val() == 2) {
    320                     jQuery("#template-2").slideDown(500);
    321                     style = 2;
    322            
    323                 } else {
    324                     jQuery("#template-2").slideUp(500);
    325                     style = 1;
    326                 }
    327             });
    328                    
    329                        
    330             </script>
    331            
    332         </td>
    333       </tr>
    334 
    335 
    336     </table>
    337 
    338       <p class="submit">
    339         <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
    340       </p>
    341 
    342   </form>
    343 </div>
    344 <?php
    345 }
    346 
    347 
    348 
    349 
    350 
    351 
    352 
    353 class cURL
    354 {
    355 
    356     var $headers;
    357 
    358     var $user_agent;
    359 
    360     var $compression;
    361 
    362     var $cookie_file;
    363 
    364     var $proxy;
    365 
    366     function cURL($cookies = TRUE, $cookie = '/tmp/cookies.txt', $compression = 'gzip', $proxy = '')
    367     {
    368         $this->headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
    369         $this->headers[] = 'Connection: Keep-Alive';
    370         $this->headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
    371         $this->user_agent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)';
    372         $this->compression = $compression;
    373         $this->proxy = $proxy;
    374         $this->cookies = $cookies;
    375         if ($this->cookies == TRUE)
    376             $this->cookie($cookie);
    377     }
    378 
    379     function cookie($cookie_file)
    380     {
    381         if (file_exists($cookie_file))
    382         {
    383             $this->cookie_file = $cookie_file;
    384         }
    385         else
    386         {
    387             fopen($cookie_file, 'w') or $this->error('The cookie file could not be opened. Make sure this directory has the correct permissions');
    388             $this->cookie_file = $cookie_file;
    389             fclose($this->cookie_file);
    390         }
    391     }
    392 
    393     function get($url)
    394     {
    395         $url = str_replace("&amp;", '&', $url);
    396 
    397         $process = curl_init($url);
    398         curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
    399         curl_setopt($process, CURLOPT_HEADER, 0);
    400         curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
    401         if ($this->cookies == TRUE)
    402             curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file);
    403         if ($this->cookies == TRUE)
    404             curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file);
    405         curl_setopt($process, CURLOPT_ENCODING, $this->compression);
    406         curl_setopt($process, CURLOPT_TIMEOUT, 10);
    407         curl_setopt($process, CURLOPT_HTTPGET, true);
    408 
    409 
    410         if ($this->proxy)
    411             curl_setopt($process, CURLOPT_PROXY, $this->proxy);
    412         curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
    413         curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
    414         $return = curl_exec($process);
    415         curl_close($process);
    416         return $return;
    417     }
    418 
    419     function post($url, $data)
    420     {
    421         $process = curl_init($url);
    422         curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
    423         curl_setopt($process, CURLOPT_HEADER, 1);
    424         curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
    425         if ($this->cookies == TRUE)
    426             curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file);
    427         if ($this->cookies == TRUE)
    428             curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file);
    429         curl_setopt($process, CURLOPT_ENCODING, $this->compression);
    430         curl_setopt($process, CURLOPT_TIMEOUT, 10);
    431         if ($this->proxy)
    432             curl_setopt($process, CURLOPT_PROXY, $this->proxy);
    433         curl_setopt($process, CURLOPT_POSTFIELDS, $data);
    434         curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
    435         curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
    436         curl_setopt($process, CURLOPT_POST, 1);
    437         $return = curl_exec($process);
    438         curl_close($process);
    439         return $return;
    440     }
    441 
    442     function error($error)
    443     {
    444         die;
    445     }
    446 }
    447 
    448 
    449 ?>
  • hearthisat/trunk/readme.txt

    r794054 r1250130  
    1010== Description ==
    1111
    12 The hearthis.at Shortcode plugin allows you to easily integrate a player widget for a track, set or group from hearthis.at into your Wordpress Blog by using a Wordpress shortcode.
    13 Use it like that in your blog post: `[hearthis]http://http://hearthis.at/LINK_TO_TRACK_SET_OR_ARTIST/[/hearthis]`
    14 It also supports these optional parameters: width, height and params.
    15 The "params" parameter will pass the given options on to the player widget.
    16 Our player accepts the following parameter options:
     12Use it in your blog post or pages by adding this Shortcode to your content: 
     13      `[hearthis]http://hearthis.at/LINK_TO_TRACK_SET_OR_ARTIST/[/hearthis]`.
    1714
    18 * hcolor = (color hex code) will paint the play button, waveform and selections in this color
    19 * theme = transparent / transparent_black
     15The Plugin also supports optional parameters. By now these are width, height and params.
     16The "params" parameter will pass the given options on to the player widget. The hearthis
     17player accepts the following parameter options:
    2018
    21 Examples:
     19* theme  = you can choose between these 2 options __transparent__ (default) or __transparent_black__
     20* width  = define the width of the widget (integer value or % value or empty string '', default is 100%)   
     21* height           =  define the height of the widget (integer value or empty string '', default is 145) 
     22* profile_height   =  define the height of the profile view (integer value or %, default is 400) 
     23* multi_height     =  define the height of the playlist view (integer value or empty string '', default is 450) 
     24* color2            =  highlight color for the waveform (not set or a hex color string with prependig #) 
     25* color            =  button and passed time color for the waveform (not set or a hex color string with prependig #) 
     26* cover            =  hides the cover img (values not set, 1 or 0) 
     27* autoplay         =  starts with autoplay (values not set, 1 or 0) 
     28* style            =  style 1 or 2 
     29* waveform         =  hide the waveform (values not set, 1 or 0) 
     30* background       =  shows the background if set (values not set, 1 or 0, if is 1 the height is 400px) 
     31* digitized_space      =  size of the spaces between the waveform blocks (integer, steps from 1 to 10, works only if style is set to 2) 
     32* liststyle       =  only aviable on playlists and will also works only with 'single' as value
     33     
    2234
    23 `[hearthis]http://hearthis.at/shawne/shawne-pornbass-12-06042013-2300-0200-uhr/[/hearthis]`
    24 Embed a track with no params
     35Examples
     36--------------
    2537
    26 `[hearthis]http://hearthis.at/set/51-7/[/hearthis]`
    27 Embed a set with no params
     38Embed a single track without params. 
     39      `[hearthis]https://hearthis.at/shawne/shawne-pornbass-12-06042013-2300-0200-uhr/[/hearthis]`
    2840
    29 `[hearthis]http://hearthis.at/shawne/[/hearthis]`
    30 Embed a user with no params
     41Embed a playlist or set without params. 
     42      `[hearthis]https://hearthis.at/crecs/set/tbase-feat-charlotte-haining-oscar-michael-unspoken-words-ep/[/hearthis]`
    3143
    32 `[hearthis params="hcolor=33e040&theme=transparent_black"]http://hearthis.at/shawne/shawne-stadtfest-chemnitz-31082013/[/hearthis]`
    33 Embeds a track with a green highlight color and black theme.
     44Embed a user without color params and autostart. 
     45      `[hearthis color="#ff5c24" color2="#33fd11" autostart="1"]http://hearthis.at/djforce/[/hearthis]`
    3446
    35 `[hearthis width="250"]http://hearthis.at/shawne/shawne-stadtfest-chemnitz-31082013/[/hearthis]`
    36 Embeds a track player with 250px width.
     47Embeds a track with a black theme and a bachground image (if set). 
     48      `[hearthis theme="transparent_black" background="1" ]https://hearthis.at/djforce/baesser-forcesicht-dnbmix/[hearthis]`
    3749
    38 `[hearthis height="400"]http://hearthis.at/set/51-7/[/hearthis]`
    39 Embed a set with 400px height
     50Embeds a track player with 300px width and a green button color. 
     51      `[hearthis width="300" color="#33fd11"]https://hearthis.at/crec/maverick-krl-c-recordings-guestmix/[/hearthis]`
     52     
     53Embeds a playlist or set with 400px height. 
     54      `[hearthis height="400"]https://hearthis.at/set/51-7/[/hearthis]`
     55
     56I embeds a hook so if you have a playlist and do set the liststyle="single" option, it will parse all tracks from this set as single tracks. 
     57      `[hearthis liststyle="single"]https://hearthis.at/crecs/set/tbase-feat-charlotte-haining-oscar-michael-unspoken-words-ep/[/hearthis]`
    4058
    4159== Installation ==
     60
     61Download the Plugin and extract the content. You should see a folder
     62named hearthisat. Move or upload this folder to your Wordpress installation
     63plugins directory. By default the wordpress plugin folder is under /wp-content/plugins/.
     64
     65After you done this go to your Wordpress Backend and activate the Plugin.
     66Now you are ready to go and can insert the hearthis Shortcodes.
     67
    4268== Frequently Asked Questions ==
    4369== Screenshots ==
     70
     71with a single Track 
     72![Track view ](/hearthisat/screenshot_track.png "the hearthis widget with a single track")
     73
     74with a playlist or set 
     75![playlist view](/hearthisat/screenshot_playlist.png "the widget with a playlist widget") 
     76
    4477
    45781. This is how the player looks.
    4679
    4780== Changelog ==
    48 = 0.5 =
    49 * First version
     81= latest version is 0.6.3 =
     82
     83= version 0.6.3 =
     84
     85+ add a shortcode option as a hook to parse all tracks from a playlist as single tracks
     86
     87= version 0.6.2 =
     88
     89+ the plugin was originaly written by Benedikt Groß the founder of hearthis.at and this release fixes old or wrong options and bug so that you can use it with the latest wordpress version and you will have the full controll of all original hearthis paramsn
     90
Note: See TracChangeset for help on using the changeset viewer.