load();
add_filter('the_content', array(&$qae, 'the_content'));
add_action('admin_menu', array(&$qae, 'admin_menu'));
if (isset($_REQUEST['qae'])) {
if (is_array($_REQUEST['qae'])) {
if (isset($_REQUEST['qae']['_nonce'])) {
if (wp_verify_nonce($_REQUEST['qae']['_nonce'], 'quick-audio-embed')) {
$qae->save($_REQUEST['qae']);
}
}
}
}
}
function plugins_loaded() {
if (version_compare(PHP_VERSION, '5.0.0') === 1) {
add_action('init', array('QuickAudioEmbed', 'init'));
} else {
add_action('admin_notices', array('QuickAudioEmbed', 'admin_notices'));
}
}
function admin_notices() {
deactivate_plugins(plugin_basename(__FILE__)); ?>
settings = array(
'dimensions' => '300x50'
);
}
// @codeCoverageIgnoreEnd
function load() {
$options = get_option('quick-audio-embed-settings');
if (is_array($options)) {
$this->settings = array_merge($this->settings, $options);
}
}
function save($info) {
foreach ($info as $key => $value) {
if (method_exists($this, "_save_${key}")) {
$result = $this->{"_save_${key}"}($value);
if (is_null($result)) {
unset($info[$key]);
} else {
$info[$key] = $result;
}
}
}
$this->settings = $info;
update_option('quick-audio-embed-settings', $info);
}
function _save_dimensions($value) {
if (is_string($value)) {
if (count($result = explode('x', $value)) === 2) {
$new_result = array();
foreach ($result as $v) {
if (is_numeric($v)) {
$new_result[] = $v;
} else {
return null;
}
}
return implode('x', array_map('intval', $new_result));
}
}
return null;
}
// @codeCoverageIgnoreStart
function admin_menu() {
add_settings_section('quick-audio-embed', __('Quick Audio Embed', 'quick-audio-embed'), array(&$this, 'media_settings'), 'media');
add_settings_field('qae-dimensions', __('Dimensions', 'quick-audio-embed'), array(&$this, 'qae_dimensions'), 'media', 'quick-audio-embed');
}
function media_settings() { ?>
Quick Audio Embed takes any linked-to MP3 file and wraps it in Google Reader's Audio Player.
The dimensions of the player as widthxheight: 300x50
]+href="(?P[^\"]+\.mp3)"[^\>]*>.*#mis', array(&$this, '_the_content_callback'), $content);
}
function _the_content_callback($matches) {
$dimensions = explode('x', $this->settings['dimensions']);
if (preg_match('#rel="(?P[^\"]+)"#', $matches[0], $rel_match) > 0) {
foreach (explode(',', $rel_match['rel']) as $part) {
$values = explode('=', $part);
$key = array_shift($values);
$values = implode('=', $values);
switch ($key) {
case 'noembed':
}
}
}
return sprintf('
', esc_url($matches['url']), esc_attr($dimensions[0]), esc_attr($dimensions[1]));
}
}
add_action('plugins_loaded', array('QuickAudioEmbed', 'plugins_loaded'));