Comments (2)
Hi
How i can add Oembed Soundcloud to my Wordpress Widgets?
I Create this widget for loading soundcloud players by using Oembed code
But don't show me soundclud player
How can fix that problem?
`<?php
class YPE_Soundcloud_Widget extends WP_Widget {
public $sc_oembedtypes = array(
'Json' => 'json+oembed',
'Xml' => 'xml+oembed'
);
public $sc_formats = array(
'json Format' => 'json',
'Xml Format' => 'xml'
);
function __construct() {
parent::__construct(
'YPE_Soundcloud_Widget',
__('YALLANPE Soundcloud Widget'),
array('description' => __('Show Soundcloud Audios'))
);
add_action('load-widgets.php', array(&$this, 'YPE_YPE_sc_wpcolorpicker'));
}
function YPE_YPE_sc_wpcolorpicker() {
wp_enqueue_style('wp-color-picker');
wp_enqueue_script('wp-color-picker');
}
function widget($args, $instance) {
extract($args);
$YPE_sc_widget_title = apply_filters('widget_title', $instance['YPE_sc_widget_title']);
$YPE_sc_oembedtype = $instance['YPE_sc_oembedtype'];
$YPE_sc_format = $instance['YPE_sc_format'];
$YPE_sc_username = $instance['YPE_sc_username'];
$YPE_sc_soundid = $instance['YPE_sc_soundid'];
$YPE_sc_maxwidth = $instance['YPE_sc_maxwidth'];
$YPE_sc_maxheight = $instance['YPE_sc_maxheight'];
$YPE_sc_color = $instance['YPE_sc_color'];
$YPE_sc_autoplay = $instance['YPE_sc_autoplay'] ? 'true' : 'false';
$YPE_sc_showcomments = $instance['YPE_sc_showcomments'] ? 'true' : 'false';
$YPE_sc_iframe = $instance['YPE_sc_iframe'] ? 'true' : 'false';
$YPE_sc_modify_color = trim($YPE_sc_color, '#');
echo $before_widget;
if($YPE_sc_widget_title) {
echo $before_title.$YPE_sc_widget_title.$after_title;
}
$YPE_sc_url = 'https://soundcloud.com/oembed?url=https://www.soundcloud.com/'.$YPE_sc_username.'/'.$YPE_sc_soundid.'/';
echo '<a rel="alternate" type="application/'.$YPE_sc_oembedtype.'" href="'.$YPE_sc_url.'&format='.$YPE_sc_format.'&maxwidth='.$YPE_sc_maxwidth.'&maxheight='.$YPE_sc_maxheight.'&color='.$YPE_sc_modify_color.'&auto_play='.$YPE_sc_autoplay.'&show_comments='.$YPE_sc_showcomments.'&iframe='.$YPE_sc_iframe.'"></a>';
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['YPE_sc_widget_title'] = strip_tags($new_instance['YPE_sc_widget_title']);
$instance['YPE_sc_oembedtype'] = strip_tags($new_instance['YPE_sc_oembedtype']);
$instance['YPE_sc_format'] = strip_tags($new_instance['YPE_sc_format']);
$instance['YPE_sc_username'] = strip_tags($new_instance['YPE_sc_username']);
$instance['YPE_sc_soundid'] = strip_tags($new_instance['YPE_sc_soundid']);
$instance['YPE_sc_maxwidth'] = strip_tags($new_instance['YPE_sc_maxwidth']);
$instance['YPE_sc_maxheight'] = strip_tags($new_instance['YPE_sc_maxheight']);
$instance['YPE_sc_color'] = strip_tags($new_instance['YPE_sc_color']);
$instance['YPE_sc_autoplay'] = strip_tags($new_instance['YPE_sc_autoplay']);
$instance['YPE_sc_showcomments'] = strip_tags($new_instance['YPE_sc_showcomments']);
$instance['YPE_sc_iframe'] = strip_tags($new_instance['YPE_sc_iframe']);
return $instance;
}
function form($instance) {
?>
<script type='text/javascript'>
jQuery(function() {
jQuery('.sc_wpcolorpicker').wpColorPicker();
});
</script>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_widget_title'); ?>"><?php echo __('Title'); ?></label>
<input id="<?php echo $this->get_field_id('YPE_sc_widget_title'); ?>" name="<?php echo $this->get_field_name('YPE_sc_widget_title'); ?>" value="<?php echo $instance['YPE_sc_widget_title']; ?>" class="widefat" type="text" />
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_oembedtype'); ?>"><?php echo __('Select Your Oembed Code Type'); ?></label>
<select id="<?php echo $this->get_field_id('YPE_sc_oembedtype'); ?>" name="<?php echo $this->get_field_name('YPE_sc_oembedtype'); ?>" >
<?php
foreach ($this->sc_oembedtypes as $sc_oembedtypes_keys => $sc_oembedtype) { ?>
<option value="<?php echo $sc_oembedtype; ?>" <?php if($instance['YPE_sc_oembedtype'] == $sc_oembedtype) echo "selected=\"selected\""; else echo ""; ?>><?php echo $sc_oembedtypes_keys; ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_format'); ?>"><?php echo __('Select Your Format Code'); ?></label>
<select id="<?php echo $this->get_field_id('YPE_sc_format'); ?>" name="<?php echo $this->get_field_name('YPE_sc_format'); ?>" >
<?php
foreach ($this->sc_formats as $sc_formats_keys => $sc_format) { ?>
<option value="<?php echo $sc_format; ?>" <?php if($instance['YPE_sc_format'] == $sc_format) echo "selected=\"selected\""; else echo ""; ?>><?php echo $sc_formats_keys; ?></option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_username'); ?>"><?php echo __('Sound Uploader/Username Name'); ?></label>
<input id="<?php echo $this->get_field_id('YPE_sc_username'); ?>" name="<?php echo $this->get_field_name('YPE_sc_username'); ?>" value="<?php echo $instance['YPE_sc_username']; ?>" class="widefat" type="text" />
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_soundid'); ?>"><?php echo __('Sound ID'); ?></label>
<input id="<?php echo $this->get_field_id('YPE_sc_soundid'); ?>" name="<?php echo $this->get_field_name('YPE_sc_soundid'); ?>" value="<?php echo $instance['YPE_sc_soundid']; ?>" class="widefat" type="text" />
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_maxwidth'); ?>"><?php echo __('Sound Maximum Width (%)'); ?> <small>(Default = 100%)</small></label>
<input id="<?php echo $this->get_field_id('YPE_sc_maxwidth'); ?>" name="<?php echo $this->get_field_name('YPE_sc_maxwidth'); ?>" value="<?php echo $instance['YPE_sc_maxwidth']; ?>" class="widefat" type="text" />
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_maxheight'); ?>"><?php echo __('Sound Maximum Height'); ?></label>
<input id="<?php echo $this->get_field_id('YPE_sc_maxheight'); ?>" name="<?php echo $this->get_field_name('YPE_sc_maxheight'); ?>" value="<?php echo $instance['YPE_sc_maxheight']; ?>" class="widefat" type="text" />
</p>
<p>
<label for="<?php echo $this->get_field_id('YPE_sc_color'); ?>"><?php echo __('Color Widget'); ?></label>
<input class="sc_wpcolorpicker" id="<?php echo $this->get_field_id('YPE_sc_color'); ?>" name="<?php echo $this->get_field_name('YPE_sc_color'); ?>" value="<?php echo $instance['YPE_sc_color']; ?>" class="widefat" type="text" />
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['YPE_sc_autoplay'], 'on'); ?> id="<?php echo $this->get_field_id('YPE_sc_autoplay'); ?>" name="<?php echo $this->get_field_name('YPE_sc_autoplay'); ?>" />
<label for="<?php echo $this->get_field_id('YPE_sc_autoplay'); ?>"><?php echo __('On/Off Autoplay') ?></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['YPE_sc_showcomments'], 'on'); ?> id="<?php echo $this->get_field_id('YPE_sc_showcomments'); ?>" name="<?php echo $this->get_field_name('YPE_sc_showcomments'); ?>" />
<label for="<?php echo $this->get_field_id('YPE_sc_showcomments'); ?>"><?php echo __('Show/Hide Comments') ?> <small>(Default = true)</small></label>
</p>
<p>
<input class="checkbox" type="checkbox" <?php checked($instance['YPE_sc_iframe'], 'on'); ?> id="<?php echo $this->get_field_id('YPE_sc_iframe'); ?>" name="<?php echo $this->get_field_name('YPE_sc_iframe'); ?>" />
<label for="<?php echo $this->get_field_id('YPE_sc_iframe'); ?>"><?php echo __('HTML5 Iframe-based') ?> <small>(Default = true)</small></label>
</p>
<?php
}
}
function Soundcloud_Widget() {
register_widget('YPE_Soundcloud_Widget');
}
add_action('widgets_init', 'Soundcloud_Widget');
?>`
from oembed.
this repo is not for oembed or wordpress support, sorry.
from oembed.
Related Issues (20)
- Refresh Oauth 2.0 tokens failed HOT 2
- Facebook garph api update to v12 HOT 2
- Add optional "license" and "license_url" parameter HOT 4
- Add test to check valid regex for providers HOT 1
- oEmbed provider for rich content without using any external tool HOT 1
- Please add bunny.net to providers.json HOT 1
- Add Mediastream as provider
- Alternative discovery mechanism HOT 3
- Provider registry contains API endpoints with patterns not described in the spec HOT 4
- How should a document with multiple authors be presented? HOT 1
- Gist or pastebin support?
- <blockquote class="twitter-tweet"><p lang="en" dir="ltr">So cute</p>— Liz C (@LizC0520) <a href="https://twitter.com/LizC0520/status/1644973800352800774?ref_src=twsrc%5Etfw">April 9, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
- <blockquote class="twitter-tweet"><p lang="en" dir="ltr">So cute</p>— Liz C (@LizC0520) <a href="https://twitter.com/LizC0520/status/1644973800352800774?ref_src=twsrc%5Etfw">April 9, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
- Support x.com URLs for Twitter/X
- providers-disabled/wiredrive.yml HOT 2
- http://creativecommons.org/licenses/by/4.0/
- Is not possible to embed youtube playlist using oembed HOT 1
- Cannot use short link of Flickr album HOT 3
- no cookies video HOT 3
- Can not get instagram embed link html HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oembed.