質問編集履歴

1

補足1 補足2追加 全ソース記載

2019/05/22 10:51

投稿

yoshio197
yoshio197

スコア38

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,16 @@
1
1
  表題についてブラウザでエラーがでます。どうすればエラーを解決できるでしょうか?
2
+
3
+
4
+
5
+ ※補足1- handsontalbeのパスをcdnにすると正しく動きますが、handsontalbe6.2.2を使用したいため質問しています。全ソースを載せます。
6
+
7
+
8
+
9
+ ※補足2 - wordpressとhandsontalbeを使用する場合の記事がありました。なので、このコードも記載しました。
10
+
11
+ https://stackoverflow.com/questions/23598044/include-handsontable-in-wordpress-plugin
12
+
13
+
2
14
 
3
15
  ```
4
16
 
@@ -28,6 +40,24 @@
28
40
 
29
41
  ```PHP
30
42
 
43
+ <?php
44
+
45
+ /*
46
+
47
+ Plugin Name: Show Text
48
+
49
+ Plugin URI: http://www.example.com/plugin
50
+
51
+ Description: プラグイン
52
+
53
+ Author: my name
54
+
55
+ Version: 0.1
56
+
57
+ Author URI: http://www.example.com
58
+
59
+ */
60
+
31
61
  class ShowText {
32
62
 
33
63
 
@@ -42,17 +72,11 @@
42
72
 
43
73
 
44
74
 
45
- function my_backend_content_scripts(){
75
+ function my_backend_content_scripts() {
46
76
 
47
- if(is_admin()){
77
+ wp_register_script( 'my_js', 'http://localhost/wordpress/wp-content/plugins/show_text/js/handsontable.full.min.js', array('jquery'), null, true );
48
78
 
49
-
50
-
51
- wp_register_script('handsontable', plugins_url() . '/js/handsontable.full.min.js');
52
-
53
- wp_enqueue_script('handsontable', array('jquery'));
79
+ wp_enqueue_script( 'my_js');
54
-
55
- }
56
80
 
57
81
  }
58
82
 
@@ -60,7 +84,7 @@
60
84
 
61
85
  function add_pages() {
62
86
 
63
- add_menu_page('AAAA', 'AAA, 'level_8', __FILE__, array($this, 'show_text_option_page'), '', 26);
87
+ add_menu_page('AAA', 'AAA', 'level_8', __FILE__, array($this, 'show_text_option_page'), '', 26);
64
88
 
65
89
  }
66
90
 
@@ -68,26 +92,92 @@
68
92
 
69
93
  function show_text_option_page(){
70
94
 
71
- ?>
95
+ ?>
72
96
 
73
- <!DOCTYPE html>
97
+ <!DOCTYPE html>
74
98
 
75
99
  <head>
76
100
 
77
- <link rel="stylesheet" href="css/handsontable.full.min.css">
101
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.css">
78
102
 
79
- <script src='http://localhost/wordpress/wp-content/plugins/show_text/js/handsontable.full.min.js' ?>></script>
80
103
 
81
-
82
104
 
83
- <script type="text/javascript">
105
+ <!--
84
106
 
85
- jQuery(document).ready(function () {
107
+ <script src="https://cdn.jsdelivr.net/npm/handsontable/dist/handsontable.full.min.js"></script>
108
+
109
+ -->
110
+
111
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
112
+
113
+ <script src="http://localhost/wordpress/wp-content/plugins/show_text/js/handsontable.full.min.js"></script>
86
114
 
87
115
 
88
116
 
89
117
 
90
118
 
119
+ <script type="text/javascript">
120
+
121
+
122
+
123
+ $(document).ready(function () {
124
+
125
+ var container = document.getElementById('hst');
126
+
127
+
128
+
129
+ hstdata = new Handsontable(container, {
130
+
131
+ data: [
132
+
133
+ ['バナナ', '100'],
134
+
135
+ ['リンゴ', '120'],
136
+
137
+ ['イチゴ', '140']
138
+
139
+ ],
140
+
141
+ colHeaders: ['名前', '値段(円)'],
142
+
143
+ colWidths: [100,100],
144
+
145
+ copyPaste: false,
146
+
147
+ language: 'ja-JP',
148
+
149
+ licenseKey:'non-commercial-and-evaluation'
150
+
151
+ });
152
+
153
+ });
154
+
155
+ </script>
156
+
157
+ </head>
158
+
159
+ <body>
160
+
161
+ <div id="hst"></div>
162
+
163
+ </body>
164
+
165
+ </html>
166
+
167
+
168
+
169
+ <?php
170
+
171
+ }
172
+
173
+
174
+
175
+ }
176
+
177
+
178
+
179
+ $showtext = new ShowText;
180
+
91
181
  ```
92
182
 
93
183
  ご教授よろしくお願いいたします。