This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
/
wp-1g.php
57 lines (51 loc) · 2 KB
/
wp-1g.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
Plugin Name:1gWordpress
Plugin URI: http://blog.1g1g.info/wp-plugin/
Description: 一个在文章中插入亦歌迷你播放器的插件。
Version: 0.5
Author: Ye Xiaoxing
Author URI: http://blog.1g1g.info/
*/
function wp1gmp_addbuttons() {
// Add only in Rich Editor mode
if ( get_user_option('rich_editing') == 'true') {
// add the button for wp25 in a new way
add_filter("mce_external_plugins", "add_wp1gmp_tinymce_plugin", 5);
add_filter('mce_buttons', 'register_wp1gmp_button', 5);
}
}
function register_wp1gmp_button($buttons) {
array_push($buttons, "separator", "wp1gmp");
return $buttons;
}
function add_wp1gmp_tinymce_plugin($plugin_array) {
$plugin_array['wp1gmp'] = get_option('siteurl').'/wp-content/plugins/1gwordpress/editor_plugin.js';
return $plugin_array;
}
function wp1gmp_mce_valid_elements($init) {
if ( isset( $init['extended_valid_elements'] )
&& ! empty( $init['extended_valid_elements'] ) ) {
$init['extended_valid_elements'] .= ',' . 'pre[lang|line|escaped]';
} else {
$init['extended_valid_elements'] = 'pre[lang|line|escaped]';
}
return $init;
}
function wp1gmp_change_tinymce_version($version) {
return ++$version;
}
function wp1g_func($atts) {
extract(shortcode_atts(array(
'play' => 'error',
), $atts));
if ($play=="error")
return '在处理亦歌代码时出错。您并未设置play参数。';
else
return '<object type="application/x-shockwave-flash" data="http://public.1g1g.com/miniplayer/miniPlayer.swf" width="200px" height="24px" id="1gMiniPlayer"><param name="movie" value="http://public.1g1g.com/miniplayer/miniPlayer.swf" /><param name="allowScriptAccess" value="always" /><param name="FlashVars" value="play='.$play.'"/><param name="wmode" value ="transparent" /></object>';
}
add_shortcode('music1g', 'wp1g_func');
add_filter('tiny_mce_before_init', 'wp1gmp_mce_valid_elements', 0);
add_filter('tiny_mce_version', 'wp1gmp_change_tinymce_version');
add_action('init', 'wp1gmp_addbuttons');
?>