質問編集履歴

2

title

2016/05/05 15:03

投稿

g-n-n
g-n-n

スコア24

test CHANGED
File without changes
test CHANGED
@@ -27,6 +27,8 @@
27
27
  使い方が上手くわからなかったので今のページを表示させているコードをここに貼ります
28
28
 
29
29
 
30
+
31
+ 参考:WordPress 3.5の新メディアアップローダーを自作プラグインやテーマに組み込む。 | Firegoby
30
32
 
31
33
  ```
32
34
 

1

コード記述

2016/05/05 15:03

投稿

g-n-n
g-n-n

スコア24

test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,123 @@
21
21
 
22
22
 
23
23
  ![ブログ設定](8980d58b3f1050fb12ccc8bd174e00c9.png)
24
+
25
+
26
+
27
+ 使い方が上手くわからなかったので今のページを表示させているコードをここに貼ります
28
+
29
+
30
+
31
+ ```
32
+
33
+ <?php
34
+
35
+ add_action ( 'admin_menu', 'blogSetting' );
36
+
37
+ function blogSetting() {
38
+
39
+ add_menu_page(
40
+
41
+ __('Blog Settings'),
42
+
43
+ __('Blog Settings'),
44
+
45
+ 'manage_options',
46
+
47
+ 'blog-settings',
48
+
49
+ 'my_plugin_options',
50
+
51
+ '',
52
+
53
+ 25
54
+
55
+ );
56
+
57
+ }
58
+
59
+ function my_plugin_options() {
60
+
61
+ if ( !current_user_can( 'manage_options' ) ) {
62
+
63
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
64
+
65
+ }
66
+
67
+ wp_enqueue_media();
68
+
69
+ public function admin_scripts()
70
+
71
+ {
72
+
73
+ wp_enqueue_media(); // メディアアップローダー用のスクリプトをロードする
74
+
75
+ // カスタムメディアアップローダー用のJavaScript
76
+
77
+ wp_enqueue_script(
78
+
79
+ 'my-media-uploader',
80
+
81
+ plugins_url("media-uploader.js", __FILE__),
82
+
83
+ array('jquery'),
84
+
85
+ filemtime(dirname(__FILE__).'/media-uploader.js'),
86
+
87
+ false
88
+
89
+ );
90
+
91
+ }
92
+
93
+ echo <<<EOT
94
+
95
+ <script>
96
+
97
+ </script>
98
+
99
+ <div class="wrap">
100
+
101
+ <h2>Blog Settings</h2>
102
+
103
+ <form method="post">
104
+
105
+
106
+
107
+ <h3>Blog Title</h3>
108
+
109
+ <input type="text" />
110
+
111
+
112
+
113
+ <h3>Blog Header Image</h3>
114
+
115
+ <div id="wp-content-media-buttons" class="wp-media-buttons">
116
+
117
+ <button type="button" id="demo-media">
118
+
119
+ <span class="wp-media-buttons-icon"></span> メディアを追加
120
+
121
+ </button>
122
+
123
+ </div>
124
+
125
+ <div id="media"></div>
126
+
127
+ <input type="checkbox" />Use Header Image
128
+
129
+ <hr>
130
+
131
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="更新">
132
+
133
+ </form>
134
+
135
+ </div>
136
+
137
+ EOT;
138
+
139
+ }
140
+
141
+
142
+
143
+ ```