• I’m having trouble placing the shortcode for CD Baby plugin, and I would appreciate your help. Please do not refer me to the plugin description page, as it has proved useless to me.

    1. The plugin description site shows four examples of shortcode that begin with [cdbaby] and end with [/cdbaby]. The shortcode I got, however, does not have that.

    2. The shortcode I got is this: <iframe name=”full” style=”width:100%;height:520px;border:0px;” src=”http://widget.cdbaby.com/83ae92cd-56da-4644-9c7a-13716742bd34/full/dark/opaque”></iframe&gt;

    3. At the WordPress Editor page for the CD Baby plugin, there is a ton of cryptic instructions, codes and information, but there is NO precise indication of WHERE EXACTLY the shortcode shown above should go. What line? After what word or what asterisk or what? Should the shortcode above be wrapped with [cdbaby] and [/cdbaby]?

    4. I tried placing it somewhere near line 12 and the whole WP Dashboard went kaput. Even my blog (claudiolessa.com) went bad, until I erased the plugin folder. Only then things got back to normal.

    5. Now I have the plugin installed again, but not activated, and I don’t want to try fiddling with the WordPress Editor until I have precise instructions. I just want to avoid the risk of another site meltdown.

    Thank you very much in advance for your attention and possible cooperation.
    Claudio Lessa
    in Brasilia, Brazil
    [email protected]

    (THIS IS THE SHORTCODE)
    <iframe name=”full” style=”width:100%;height:520px;border:0px;” src=”http://widget.cdbaby.com/9639ed8d-06f5-407f-9194-2788c283e1e7/full/dark/opaque”></iframe&gt;

    (IS THIS THE PAGE WHERE THE SHORTCODE SHOULD BE INSERTED?
    W H E R E, E X A C T L Y?)

    <?php
    /*
    Plugin Name: CD Baby Music Player Shortcode
    Plugin URI: http://ww.wp.xz.cn/extend/plugins/cdbaby-shortcode/
    Description: Embeds the CD Baby HTML5 Player into WordPress using the cdbaby shortcode. Example: [cdbaby]DA770544-7C91-45D9-8372-104BCD7FB47F[/cdbaby]
    Version: 1.0.3
    Author: CD Baby
    Author URI: http://cdbaby.com
    License: GPLv2

    */

    /* Register shortcode*/
    add_shortcode(‘cdbaby’, ‘cdbaby_shortcode’);

    /**
    * CD Baby (cdbaby) shortcode.
    *
    * This implements the functionality of the playlist shortcode for displaying
    * a collection of WordPress audio or video files in a post.

    *
    * @param {string|array} $attr CD Baby shortcode attributes.
    * @param string $content Content (typically the playerId) passed within [cdbaby] tags.
    * @return string Music Player HTML.
    */
    function cdbaby_shortcode($atts, $content = null) {

    // Custom shortcode options
    $shortcode_options = is_array($atts) ? $atts : array();

    if ($content != NULL){
    $shortcode_options = array_merge(array(‘playerid’ => trim($content)), $shortcode_options);
    }

    // Default options
    $default_options = array(
    ‘width’ => ‘100%’,
    ‘height’ => ‘100px’,
    ‘type’ => ‘mini’, // mini|album|square|full
    ‘theme’ => ‘light’, // light|dark
    ‘transparent’ => ‘false’ // true|false
    );

    // shortcode options
    $options = array_merge( $default_options, $shortcode_options);

    // The “playerId” option is required
    if (!isset($options[‘playerid’])) {
    return ‘<p>CD Baby Player ID not found</p>’;
    } else {
    $options[‘playerId’] = trim($options[‘playerid’]);
    }
    return create_player($options);
    }

    /**
    * Create Player Emded code.
    *
    * Output Player HTML
    *
    * @param {array} $options Player options
    * @return string Music Player HTML.
    */
    function create_player($options) {

    // Base URL without last slash
    $base = ‘//widget.cdbaby.com’;
    // Build URL
    $url = sprintf(‘%s/%s/%s/%s/%s’, $base, $options[‘playerId’], $options[‘type’], $options[‘theme’], $options[‘transparent’]);
    // Set default width if not defined
    $width = isset($options[‘width’]) && $options[‘width’] !== 0 ? $options[‘width’] : ‘100%’;
    // Set default height if not defined
    $height = isset($options[‘height’]) && $options[‘height’] !== 0 ? $options[‘height’] : ‘100px’;

    switch ($options[‘type’]) {
    case ‘mini’:
    return sprintf(‘<iframe name=”mini” style=”border:0px;width:%s;height:%s;” src=”%s”></iframe>’, $width, $height, $url);
    case ‘album’:
    return sprintf(‘<div style=”max-width:600px;max-height:760px;”><div style=”position: relative;height: 0;overflow: hidden;padding-bottom:calc(100%% + 200px);”><iframe name=”album” style=”position:absolute;top:0px;left:0px;width:100%%;height:100%%;border:0px;” src=”%s”></iframe></div></div>’, $url);
    case ‘square’:
    return sprintf(‘<div style=”max-width:600px;max-height:625px;”><div style=”position: relative;height: 0;overflow: hidden;padding-bottom:calc(100%% + 30px);”><iframe name=”square” style=”position:absolute;top:0px;left:0px;width:100%%;height:100%%;border:0px;” src=”%s”></iframe></div></div>’, $url);
    case ‘full’:
    return sprintf(‘<iframe name=”full” style=”width:100%%;height:520px;border:0px;” src=”%s”/>’, $url);
    }
    }

    function is_valid_guid($id){
    return preg_match(‘/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/’, trim($id)) > 0;
    }
    ?>

    https://ww.wp.xz.cn/plugins/cd-baby-player-emded/

The topic ‘One more attempt at embedding’ is closed to new replies.