/** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form($instance) { if (isset($instance['title'])) { $title = $instance['title']; } else { $title = __('Latest', 'text_domain'); } ?> <!-- Title --> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <!-- Users --> <p> <label for="<?php echo $this->get_field_id('user'); ?> "><?php _e('Username:'******'user'); ?> " id="<?php echo $this->get_field_id('user'); ?> " class="widefat"> <?php $options = get_option('soundcloud_is_gold_options'); foreach ($options['soundcloud_is_gold_users'] as $user) { ?> <option value="<?php echo $user[0]; ?> "<?php selected($instance['user'], $user[0]); ?> ><?php _e($user[0]); ?> </option> <?php } ?> <option value="randomUser"<?php selected($instance['user'], "randomUser"); ?> ><?php _e("Pick a Random User"); ?> </option> <option value="randomUsers"<?php selected($instance['user'], "randomUsers"); ?> ><?php _e("Pick a Random User per Track"); ?> </option> </select> </p> <!-- Main options --> <?php $autoplay = $instance['autoplay'] ? 'checked="checked"' : ''; $comments = $instance['comments'] ? 'checked="checked"' : ''; $artwork = $instance['artwork'] ? 'checked="checked"' : ''; ?> <p> <label for=""><?php _e('Settings:'); ?> </label> <select name="<?php echo $this->get_field_name('format'); ?> " id="<?php echo $this->get_field_id('format'); ?> " class="widefat"> <option value="tracks"<?php selected($instance['format'], "tracks"); ?> ><?php _e("tracks"); ?> </option> <option value="favorites"<?php selected($instance['format'], "favorites"); ?> ><?php _e("favorites"); ?> </option> <option value="sets"<?php selected($instance['format'], "sets"); ?> ><?php _e("sets"); ?> </option> </select> <br/> <br/> <select name="<?php echo $this->get_field_name('behavior'); ?> " id="<?php echo $this->get_field_id('behavior'); ?> " class="widefat"> <option value="latest"<?php selected($instance['behavior'], "latest"); ?> ><?php _e("Latest"); ?> </option> <option value="random"<?php selected($instance['behavior'], "random"); ?> ><?php _e("Random"); ?> </option> </select> <br/> <br/> <select name="<?php echo $this->get_field_name('number'); ?> " id="<?php echo $this->get_field_id('number'); ?> " class="widefat"> <?php for ($i = 1; $i <= 5; $i++) { ?> <option value="<?php echo $i; ?> "<?php selected($instance['number'], $i); ?> ><?php _e($i); ?> </option> <?php } ?> </select> <br/> <br/> <input class="checkbox" type="checkbox" <?php echo $autoplay; ?> id="<?php echo $this->get_field_id('autoplay'); ?> " name="<?php echo $this->get_field_name('autoplay'); ?> " /> <label for="<?php echo $this->get_field_id('autoplay'); ?> "><?php _e('Play Automatically'); ?> </label> <br/> <input class="checkbox" type="checkbox" <?php echo $comments; ?> id="<?php echo $this->get_field_id('comments'); ?> " name="<?php echo $this->get_field_name('comments'); ?> " /> <label for="<?php echo $this->get_field_id('comments'); ?> "><?php _e('Show comments <small>(Standard and Artwork player)</small>'); ?> </label> <br/> <input class="checkbox" type="checkbox" <?php echo $artwork; ?> id="<?php echo $this->get_field_id('artwork'); ?> " name="<?php echo $this->get_field_name('artwork'); ?> " /> <label for="<?php echo $this->get_field_id('artwork'); ?> "><?php _e('Show Artwork <small>(html5 player)</small>'); ?> </label> </p> <!-- Player --> <p> <label for="<?php echo $this->get_field_id('playertype'); ?> "><?php _e('Player Type:'); ?> </label> <select name="<?php echo $this->get_field_name('playertype'); ?> " id="<?php echo $this->get_field_id('playertype'); ?> " class="widefat"> <?php $playertypes = array("Mini", "Standard", "Artwork", "html5"); foreach ($playertypes as $playertype) { ?> <option value="<?php echo $playertype; ?> "<?php selected($instance['playertype'], $playertype); ?> ><?php _e($playertype); ?> </option> <?php } ?> </select> </p> <!-- Width --> <?php ?> <p> <label for=""><?php _e('Width:'); ?> </label> <p> <input type="radio" <?php checked($instance['type'], "wp"); ?> value="wp" id="wp" name="<?php echo $this->get_field_name('type'); ?> " /><label for="wp">Media Width</label> <br/> <select name="<?php echo $this->get_field_name('wp'); ?> " id="<?php echo $this->get_field_id('wp'); ?> " class="widefat"> <?php foreach (get_soundcloud_is_gold_wordpress_sizes() as $key => $soundcloudIsGoldMediaSize) { ?> <option value="<?php echo $soundcloudIsGoldMediaSize[0]; ?> " <?php selected($instance['wp'], $soundcloudIsGoldMediaSize[0]); ?> ><?php _e($key . ': ' . $soundcloudIsGoldMediaSize[0]); ?> </option> <?php } ?> </select> </p> <p> <input type="radio" <?php checked($instance['type'], "custom"); ?> value="custom" id="custom" name="<?php echo $this->get_field_name('type'); ?> " /><label for="custom">Custom Width</label> <br/> <input type="text" value="<?php echo $instance['custom'] ? $instance['custom'] : "100%"; ?> " id="<?php echo $this->get_field_id('custom'); ?> " name="<?php echo $this->get_field_name('custom'); ?> "/> </p> </p> <!-- Classes --> <p> <label for="<?php echo $this->get_field_id('classes'); ?> "><?php _e('Classes <small>(no commas)</small>:'); ?> </label> <input type="text" value="<?php echo $instance['classes']; ?> " id="<?php echo $this->get_field_id('classes'); ?> " name="<?php echo $this->get_field_name('classes'); ?> "/> </p> <?php }
function soundcloud_is_gold_options() { $options = get_option('soundcloud_is_gold_options'); //printl($options); $soundcloudIsGoldActiveUser = isset($options['soundcloud_is_gold_active_user']) ? $options['soundcloud_is_gold_active_user'] : ''; $soundcloudIsGoldUsers = isset($options['soundcloud_is_gold_users']) ? $options['soundcloud_is_gold_users'] : ''; $soundcloudIsGoldSettings = isset($options['soundcloud_is_gold_settings']) ? $options['soundcloud_is_gold_settings'] : ''; $soundcloudIsGoldPlayerType = isset($options['soundcloud_is_gold_playerType']) ? $options['soundcloud_is_gold_playerType'] : ''; $soundcloudIsGoldPlayerTypeDefault = empty($soundcloudIsGoldPlayerType) ? TRUE : FALSE; $soundcloudIsGoldWidthSettings = isset($options['soundcloud_is_gold_width_settings']) ? $options['soundcloud_is_gold_width_settings'] : ''; $soundcloudIsGoldClasses = isset($options['soundcloud_is_gold_classes']) ? $options['soundcloud_is_gold_classes'] : ''; $soundcloudIsGoldColor = isset($options['soundcloud_is_gold_color']) ? $options['soundcloud_is_gold_color'] : ''; $soundcloudIsGoldApiCall = 'http://api.soundcloud.com/users/' . $soundcloudIsGoldActiveUser . '/tracks.xml?limit=1&client_id=9rD2GrGrajkmkw5eYFDp2g'; $soundcloudIsGoldApiResponse = get_soundcloud_is_gold_api_response($soundcloudIsGoldApiCall); if (isset($soundcloudIsGoldApiResponse['response']) && $soundcloudIsGoldApiResponse['response']) { foreach ($soundcloudIsGoldApiResponse['response'] as $soundcloudMMLatestTrack) { $soundcouldMMId = (string) $soundcloudMMLatestTrack->id; } } $soundcouldMMShortcode = '[soundcloud id=' . $soundcouldMMId . ']'; ?> <script type="text/javascript"> //Set default Soundcloud Is Gold Settings <?php get_soundcloud_is_gold_default_settings_for_js(); ?> </script> <div class="soundcloudMMWrapper soundcloudMMOptions soundcloudMMMainWrapper"> <div id="soundcloudMMTop" class="darkGreyGradient"> <a id="soundcloudMMLogo" class="orangeGradient" href="http://www.soundcloud.com" title="visit SoundCloud website"><img src="<?php echo SIG_PLUGIN_DIR; ?> /images/soundcloud-logo-sc.png" width="107" height="71" alt="Soundcloud Logo"/></a> <a id="soundcloudMMHeader" class="mediumGreyGradient textShadow" href="http://www.mightymess.com/soundcloud-is-gold-wordpress-plugin" alt="Visit Mighty Mess for more cool stuff"> <span class="soundcloudMMTitle">SoundCloud is gold <small>by Thomas Michalak</small></span> <span class="soundcloudMMUrl">www.mightymess.com/soundcloud-is-gold-wordpress-plugin</span> </a> <p id="soundcloudMMVersion">version <?php echo get_soundcloud_is_gold_version($options); ?> </p> </div> <div id="soundcloudMMMain" class="lightBlueGradient"> <form method="post" action="options.php" id="soundcloudMMMainForm" name="soundcloudMMMainForm" class=""> <p class="hidden soundcloudMMId" id="soundcloudMMId-<?php echo $soundcouldMMId; ?> "><?php echo $soundcouldMMId; ?> </p> <?php settings_fields('soundcloud_is_gold_options'); ?> <ul id="soundcloudMMSettings"> <!-- Username --> <li class="soundcloudMMBox"><label class="optionLabel">User Name</label> <?php get_soundcloud_is_gold_username_interface($options, $soundcloudIsGoldUsers); ?> </li> <!-- Default Settings --> <li class="soundcloudMMBox"><label class="optionLabel">Default Settings</label> <ul class="subSettings checkboxes"> <li><input type="checkbox" <?php echo isset($soundcloudIsGoldSettings[0]) && $soundcloudIsGoldSettings[0] ? 'checked="checked"' : ''; ?> name="soundcloud_is_gold_options[soundcloud_is_gold_settings][0]" value="true" class="soundcloudMMAutoPlay" id="soundcloudMMAutoPlay"/><label for="soundcloudMMAutoPlay">Play Automatically</label></li> <li><input type="checkbox" <?php echo isset($soundcloudIsGoldSettings[1]) && $soundcloudIsGoldSettings[1] ? 'checked="checked"' : ''; ?> name="soundcloud_is_gold_options[soundcloud_is_gold_settings][1]" value="true" class="soundcloudMMShowComments" id="soundcloudMMShowComments"/><label for="soundcloudMMShowComments">Show comments <small>(Standard and Artwork player)</small></label></li> <li><input type="checkbox" <?php echo isset($soundcloudIsGoldSettings[2]) && $soundcloudIsGoldSettings[2] ? 'checked="checked"' : ''; ?> name="soundcloud_is_gold_options[soundcloud_is_gold_settings][2]" value="true" class="soundcloudMMShowArtwork" id="soundcloudMMShowArtwork"/><label for="soundcloudMMShowArtwork">Show Artwork <small>(html5 player)</small></label></li> </ul> </li> <!-- Player Type --> <li class="soundcloudMMBox"><label class="optionLabel">Default Player Type</label> <ul class="subSettings radios"> <?php foreach (get_soundcloud_is_gold_player_types() as $type) { ?> <li><input name="soundcloud_is_gold_options[soundcloud_is_gold_playerType]" id="<?php echo $type; ?> " class="soundcloudMMPlayerType" type="radio" value="<?php echo $type; ?> " <?php if ($soundcloudIsGoldPlayerTypeDefault && $type == 'Standard') { echo 'checked="checked"'; } else { echo $soundcloudIsGoldPlayerType === $type ? 'checked="checked"' : ''; } ?> /><label for="<?php echo $type; ?> "><?php echo $type; if ($type == 'Artwork') { echo ' <small>(not available on free soundcloud account)</small>'; } if ($type == 'html5') { echo ' <small>new! (beta)</small>'; } ?> </label></li> <?php } ?> </ul> </li> <!-- Width --> <li class="soundcloudMMBox"><label class="optionLabel">Default Width</label> <ul id="soundcloudMMWidthSetting" class="subSettings texts"> <li> <input name="soundcloud_is_gold_options[soundcloud_is_gold_width_settings][type]" <?php echo $soundcloudIsGoldWidthSettings['type'] == "wp" ? 'checked="checked"' : ''; ?> id="soundcloudMMWpWidth" value="wp" type="radio" class="soundcloudMMWpWidth soundcloudMMWidthType radio"/><label for="soundcloudMMWpWidth">Media Width</label> <select class="soundcloudMMInput soundcloudMMWidth" name="soundcloud_is_gold_options[soundcloud_is_gold_width_settings][wp]"> <?php foreach (get_soundcloud_is_gold_wordpress_sizes() as $key => $soundcloudIsGoldMediaSize) { ?> <?php //First Time, then Other Times if ($soundcloudIsGoldWidthSettings['wp'] == 'medium') { $soundcloudIsGoldMediaSelected = $key == $soundcloudIsGoldWidthSettings['wp'] ? 'selected="selected"' : ''; } else { $soundcloudIsGoldMediaSelected = $soundcloudIsGoldMediaSize[0] == $soundcloudIsGoldWidthSettings['wp'] ? 'selected="selected"' : ''; } ?> <option <?php echo $soundcloudIsGoldMediaSelected; ?> value="<?php echo $soundcloudIsGoldMediaSize[0]; ?> " class="soundcloudMMWpSelectedWidth"><?php echo $key . ': ' . $soundcloudIsGoldMediaSize[0]; ?> </option> <?php } ?> </select> </li> <li> <input name="soundcloud_is_gold_options[soundcloud_is_gold_width_settings][type]" <?php echo $soundcloudIsGoldWidthSettings['type'] == "custom" ? 'checked="checked"' : ''; ?> id="soundcloudMMCustomWidth" value="custom" type="radio" class="soundcloudMMCustomWidth soundcloudMMWidthType radio"/><label for="soundcloudMMCustomWidth">Custom Width</label> <input name="soundcloud_is_gold_options[soundcloud_is_gold_width_settings][custom]" id="soundcloudMMCustomSelectedWidth" class="soundcloudMMInput soundcloudMMWidth soundcloudMMCustomSelectedWidth" type="text" name="soundcloud_is_gold_options[soundcloudMMCustomSelectedWidth]" value="<?php echo $soundcloudIsGoldWidthSettings['custom']; ?> " /> </li> </ul> </li> <!-- Color and Classes --> <li class="soundcloudMMBox"><label class="optionLabel">Extras</label> <ul class="subSettings texts"> <li> <label>Color</label> <div class="soundcloudMMColorPickerContainer" id="soundcloudMMColorPickerContainer"> <input type="text" class="soundcloudMMInput soundcloudMMColor" id="soundcloudMMColor" name="soundcloud_is_gold_options[soundcloud_is_gold_color]" value="<?php echo $soundcloudIsGoldColor; ?> " style="background-color:<?php echo $soundcloudIsGoldColor; ?> "/><a href="#" class="soundcloudMMBt soundcloudMMBtSmall inline blue soundcloudMMRounder soundcloudMMResetColor">reset to default</a> <div id="soundcloudMMColorPicker" class="shadow soundcloudMMColorPicker"><div id="soundcloudMMColorPickerSelect" class="soundcloudMMColorPickerSelect"></div><a id="soundcloudMMColorPickerClose" class="blue soundcloudMMBt soundcloudMMColorPickerClose">done</a></div> </div> </li> <li class="clear"> <label>Classes <small>(no commas)</small></label><input class="soundcloudMMInput soundcloudMMClasses" type="text" name="soundcloud_is_gold_options[soundcloud_is_gold_classes]" value="<?php echo $soundcloudIsGoldClasses; ?> " /> </li> </ul> </li> <!-- Advance Options --> <!-- <li class="hidden soundcloudMMBox"><label class="optionLabel">Advanced Options</label> <?php //soundcloud_is_gold_advanced_options() ?> </li> --> <!-- Preview --> <li class="soundcloudMMBox"><label class="optionLabel previewLabel">Live Preview <small>(your latest track)</small></label> <?php if ($soundcloudIsGoldApiResponse['response']) { ?> <p class="soundcloudMMEmbed soundcloudMMEmbedOptions" style="text-align:center;"> <!-- Soundcloud Preview here --> </p> <p class="soundcloudMMLoading soundcloudMMPreviewLoading" style="display:none"></p> <?php } else { ?> <!-- Error getting XML --> <div class="soundcloudMMXmlError"><p><?php echo $soundcloudIsGoldApiResponse['error'] ? $soundcloudIsGoldApiResponse['error'] : "Oups! There's been a error while getting the tracks from soundcloud. Please reload the page."; ?> </p></div> <?php } ?> </li> </ul> <!-- Submit --> <p id="soundcloudMMSubmit"><input type="submit" name="Submit" value="<?php _e('Save Your SoundCloud Settings'); ?> " class="soundcloudMMBt blue"/></p> </form> </div> <ul id="soundcloudMMExtras" class="lightGreyGradient"> <li><a href="http://soundcloud.com/t-m" title="TM's music on SoundCloud" class="soundcloudMMBt orangeGradient soundcloudMMRounder">TM on SoundCloud</a></li> <li><a href="http://www.mightymess.com" title="Thomas Michalak's Website" class="soundcloudMMBt orangeGradient soundcloudMMRounder">More Mighty Mess</a></li> <li><a href="http://wordpress.org/tags/soundcloud-is-gold?forum_id=10" title="Soundcloud is Gold Forum" class="soundcloudMMBt orangeGradient soundcloudMMRounder">Forum</a></li> <li> <form class="soundcloudMMBtForm" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="9VGA6PYQWETGY"> <input type="submit" name="submit" value="Donate via PayPal" class="soundcloudMMBt darkGrey soundcloudMMRounder" alt="PayPal - The safer, easier way to pay online."> <img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form> </li> </ul> <p id="disclaimer">SoundCloud and SoundCloud Logo are trademarks of SoundCloud Ltd.</p> </div> <?php }