1 | <?php
|
---|
2 | /*
|
---|
3 | Plugin Name: Plugin for XPressME
|
---|
4 | Plugin URI: http://ja.xpressme.info
|
---|
5 | Description: Plugin for XPressME (custom function,filter,action)
|
---|
6 | Author: toemon
|
---|
7 | Version: 1.0
|
---|
8 | Author URI: http://ja.xpressme.info
|
---|
9 | */
|
---|
10 | require_once('xpressme_class.php');
|
---|
11 |
|
---|
12 | require_once dirname( __FILE__ ).'/include/custom_functions.php' ; // XPressME functions for themes
|
---|
13 | require_once dirname( __FILE__ ).'/include/xpress_common_functions.php' ;
|
---|
14 |
|
---|
15 | $xoops_db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
---|
16 | $xoops_db->prefix = get_xoops_prefix();
|
---|
17 | $xoops_db->tables = array('modules', 'newblocks', 'users');
|
---|
18 |
|
---|
19 | $xpress_config = new XPressME_Class();
|
---|
20 |
|
---|
21 | require_once dirname( __FILE__ ).'/include/pluggable-override.php' ;
|
---|
22 | require_once dirname( __FILE__ ).'/include/functions_for_wp_old.php' ;
|
---|
23 |
|
---|
24 | if (!is_wordpress_style() && ( !empty($xpress_config->theme_select) || $xpress_config->theme_select != 'use_wordpress_select') ){
|
---|
25 | add_filter('stylesheet', 'xpress_Stylesheet');
|
---|
26 | add_filter('template', 'xpress_ThemeTemplate');
|
---|
27 | }
|
---|
28 | function xpress_Stylesheet($stylesheet) {
|
---|
29 | global $xpress_config;
|
---|
30 | $theme = $xpress_config->theme_select;
|
---|
31 | $theme = get_theme($theme);
|
---|
32 |
|
---|
33 | if (empty($theme)) {
|
---|
34 | return $stylesheet;
|
---|
35 | }
|
---|
36 | return $theme['Stylesheet'];
|
---|
37 | }
|
---|
38 |
|
---|
39 | function xpress_ThemeTemplate($template) {
|
---|
40 | global $xpress_config;
|
---|
41 | $theme = $xpress_config->theme_select;
|
---|
42 | $theme = get_theme($theme);
|
---|
43 |
|
---|
44 | if (empty($theme)) {
|
---|
45 | return $template;
|
---|
46 | }
|
---|
47 | return $theme['Template'];
|
---|
48 | }
|
---|
49 |
|
---|
50 | function my_plugin_menu()
|
---|
51 | {
|
---|
52 | global $xpress_config,$xoops_config;
|
---|
53 |
|
---|
54 | $plugin_url = WP_PLUGIN_URL."/xpressme/";
|
---|
55 |
|
---|
56 | // Add a new top-level menu:
|
---|
57 | add_menu_page('XPressME','XPressME', 8, __FILE__, 'display_option_page' , $plugin_url.'/images/menu_icon.png');
|
---|
58 | // Add submenus to the custom top-level menu:
|
---|
59 | add_submenu_page(__FILE__, __('Display Settings', 'xpressme'), __('Display Settings', 'xpressme'), 8, __FILE__, 'display_option_page');
|
---|
60 | add_submenu_page(__FILE__, __('Integration Settings', 'xpressme'), __('Integration Settings', 'xpressme'), 8, 'integration_option_page', 'integration_option_page');
|
---|
61 | add_submenu_page(__FILE__, __('Other Settings', 'xpressme'), __('Other Settings', 'xpressme'), 8, 'other_option_page', 'other_option_page');
|
---|
62 | // if (function_exists('wp_remote_get'))
|
---|
63 | if(!xpress_is_multiblog() || xpress_is_multiblog_root()){
|
---|
64 | add_submenu_page(__FILE__, __('Upgrade', 'xpressme'), __('Upgrade', 'xpressme'), 8, 'upgrade_page', 'upgrade_page');
|
---|
65 | add_submenu_page(__FILE__, __('to Modules Admin', 'xpressme'), __('to Modules Admin', 'xpressme'), 8, 'redirect_xoops_admin', 'redirect_xoops_admin');
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | function blog_charset_check()
|
---|
70 | {
|
---|
71 | $lang= WPLANG;
|
---|
72 | $blog_charset = get_option('blog_charset');
|
---|
73 | switch ($lang) {
|
---|
74 | case 'ja_EUC':
|
---|
75 | if ($blog_charset !=='EUC-JP') update_option('blog_charset', 'EUC-JP' );
|
---|
76 | break;
|
---|
77 | case 'ja_UTF':
|
---|
78 | case 'ja':
|
---|
79 | if ($blog_charset !=='UTF-8') update_option('blog_charset', 'UTF-8' );
|
---|
80 | break;
|
---|
81 | default:
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | // enable multibyte username
|
---|
86 | if( ! function_exists( 'sanitize_user_multibyte_at_update' ) ){
|
---|
87 | function sanitize_user_multibyte_at_update($username, $raw_username, $strict){
|
---|
88 | if (isset($_POST['action']) && $_POST['action'] == 'update'){
|
---|
89 | if ($raw_username !== "" && $username !== $raw_username){
|
---|
90 | return $raw_username;
|
---|
91 | }
|
---|
92 | }
|
---|
93 | return $username;
|
---|
94 | }
|
---|
95 | }
|
---|
96 | add_filter('sanitize_user', "sanitize_user_multibyte_at_update" ,10,3);
|
---|
97 |
|
---|
98 | add_action('admin_menu', 'my_plugin_menu');
|
---|
99 |
|
---|
100 | add_filter("upload_dir",array(&$xpress_config, 'xpress_upload_filter'), 1); // Change wp-include/wp_upload_dir()
|
---|
101 | if (!$xpress_config->is_save_post_revision){
|
---|
102 | remove_action( 'pre_post_update', 'wp_save_post_revision' ); // Not Save Post Revision
|
---|
103 | }
|
---|
104 | add_action("wp_meta" , "wp_meta_add_xpress_menu"); // add xpress menu in wp_meta
|
---|
105 |
|
---|
106 | //XOOPS Bloack Cache Refresh
|
---|
107 | add_action("comment_post", "block_cache_refresh");
|
---|
108 | add_action("edit_comment", "block_cache_refresh");
|
---|
109 | add_action("wp_set_comment_status","block_cache_refresh"); //wp_delete_comment() at deleted
|
---|
110 | add_action("deleted_post", "block_cache_refresh");
|
---|
111 | add_action("publish_post", "block_cache_refresh");
|
---|
112 | add_action("edit_post", "block_cache_refresh");
|
---|
113 | add_action("private_to_published", "block_cache_refresh");
|
---|
114 | add_action("transition_post_status", "block_cache_refresh");
|
---|
115 |
|
---|
116 | add_action("the_content", "set_post_views_count");
|
---|
117 |
|
---|
118 | // blog charset check
|
---|
119 | add_action("init", "blog_charset_check");
|
---|
120 |
|
---|
121 |
|
---|
122 | //XOOPS notifiction
|
---|
123 | require_once dirname( __FILE__ ).'/include/notify_functions.php' ;
|
---|
124 | add_action("transition_post_status", "onaction_publish_post_notify" ,10 , 3);
|
---|
125 | // add_action("edit_post", "onaction_edit_post_notify");
|
---|
126 | add_action("comment_post", "onaction_comment_notify");
|
---|
127 | // add_action("approve_comment" , "onaction_comment_apobe_notify");
|
---|
128 | add_action("wp_set_comment_status" , "onaction_comment_apobe_notify");
|
---|
129 |
|
---|
130 | // user data sync user_sync_to_xoops($user_id)
|
---|
131 | require_once dirname( __FILE__ ).'/include/user_sync_xoops.php' ;
|
---|
132 | add_action('profile_update', 'user_sync_to_xoops');
|
---|
133 | add_action('user_register', 'user_sync_to_xoops');
|
---|
134 | add_action('delete_blog', 'blog_group_role_delete',10,2); //at multi blog delete
|
---|
135 | add_action('wpmu_new_blog', 'blog_group_role_add',10,2); //at multi blog delete
|
---|
136 |
|
---|
137 | //require_once('../include/custom_functions.php');
|
---|
138 |
|
---|
139 | //D3Forum Comment Integration
|
---|
140 | if ($xpress_config->is_use_d3forum){
|
---|
141 | require_once dirname( __FILE__ ).'/include/d3forum_comment_synchro.php' ;
|
---|
142 | add_action("comment_post", "onaction_comment_post");
|
---|
143 | add_action("edit_comment", "onaction_edit_comment");
|
---|
144 | add_action("delete_comment","onaction_delete_comment");
|
---|
145 | add_action("delete_post", "onaction_delete_post");
|
---|
146 | add_action("wp_set_comment_status" , "onaction_comment_apobe");
|
---|
147 | add_action("publish_post", "onaction_comment_close");
|
---|
148 |
|
---|
149 | // comment trashed untrashed action
|
---|
150 | add_action("trashed_post_comments", "onaction_trashed_post_comments");
|
---|
151 | add_action("untrashed_post_comments", "onaction_untrashed_post_comments");
|
---|
152 | add_action("trashed_comment", "onaction_trashed_comment");
|
---|
153 | add_action("untrashed_comment", "onaction_untrashed_comment");
|
---|
154 |
|
---|
155 | add_filter('comments_template', "disp_d3forum_comments" );
|
---|
156 | }
|
---|
157 |
|
---|
158 | //The trackback and the pingback are excluded from the count of the comment.
|
---|
159 | add_filter('get_comments_number', 'xpress_comment_count', 0);
|
---|
160 |
|
---|
161 | // Query filter for MultiUser
|
---|
162 | add_filter('query','xpress_query_filter');
|
---|
163 | //add_action("init", "xpress_set_author_cookie");
|
---|
164 | if(xpress_is_wp_version('<','2.1')){
|
---|
165 | // It is called before parse_request() makes $GET.
|
---|
166 | add_action("query_vars", "xpress_set_author_cookie");
|
---|
167 | } else {
|
---|
168 | // It is called at the end of parse_request().
|
---|
169 | add_filter('request', 'xpress_set_author_cookie');
|
---|
170 | }
|
---|
171 |
|
---|
172 | // SQL debug windows
|
---|
173 | add_filter('query', array(&$xpress_config, 'xpress_sql_debug'));
|
---|
174 | add_action('admin_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
175 | add_action('wp_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
176 |
|
---|
177 | // Multi Blog default Themes
|
---|
178 | function my_new_blog_template($blog_id) {
|
---|
179 | $default_theme = 'xpress_default';
|
---|
180 | update_blog_option($blog_id, 'template',$default_theme);
|
---|
181 | update_blog_option($blog_id, 'stylesheet', $default_theme);
|
---|
182 | }
|
---|
183 | add_action('wpmu_new_blog','my_new_blog_template',0,1);
|
---|
184 |
|
---|
185 | function redirect_xoops_admin()
|
---|
186 | {
|
---|
187 | global $xoops_config,$xpress_config;
|
---|
188 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
189 | wp_redirect($xoops_admin_url);
|
---|
190 | }
|
---|
191 |
|
---|
192 | function display_option_page()
|
---|
193 | {
|
---|
194 | global $xoops_config,$xpress_config;
|
---|
195 |
|
---|
196 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
197 |
|
---|
198 | $do_message ='';
|
---|
199 | if (!empty($_POST['submit_update'])) {
|
---|
200 | $xpress_config->ReadPostData($_POST);
|
---|
201 | $xpress_config->SettingValueWrite('update');
|
---|
202 | } else if (isset($_POST['submit_reset'])) {
|
---|
203 | $xpress_config->setDefault();
|
---|
204 | $xpress_config->SettingValueWrite('update');
|
---|
205 | }
|
---|
206 |
|
---|
207 | echo '<div class="wrap">'."\n";
|
---|
208 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
209 | echo '<h2>' . __('XPressME Display Setting', 'xpressme') . "</h2><br>\n";
|
---|
210 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
211 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
212 | echo '<table class="form-table">'."\n";
|
---|
213 | echo $xpress_config->viewer_type_option();
|
---|
214 | echo $xpress_config->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
215 | __('Thema Sidebar Display','xpressme'),
|
---|
216 | __('YES','xpressme'),
|
---|
217 | __('NO','xpressme')
|
---|
218 | );
|
---|
219 | echo $xpress_config->single_post_navi_option();
|
---|
220 | echo $xpress_config->posts_page_navi_option();
|
---|
221 | echo $xpress_config->excerpt_option();
|
---|
222 | echo $xpress_config->dashboard_display_option();
|
---|
223 | echo "</table>\n";
|
---|
224 |
|
---|
225 | echo '<p class="submit">'."\n";
|
---|
226 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
227 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
228 | echo "</p>\n";
|
---|
229 |
|
---|
230 | echo "</form>\n" ;
|
---|
231 | echo "</div>\n";
|
---|
232 | }
|
---|
233 |
|
---|
234 | function integration_option_page()
|
---|
235 | {
|
---|
236 | global $xoops_config,$xpress_config,$blog_id;
|
---|
237 |
|
---|
238 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
239 |
|
---|
240 | $do_message ='';
|
---|
241 | if (!empty($_POST['submit_update'])) {
|
---|
242 | $xpress_config->ReadPostData($_POST);
|
---|
243 | $xpress_config->SettingValueWrite('update');
|
---|
244 | } else if (isset($_POST['submit_reset'])) {
|
---|
245 | $xpress_config->setDefault();
|
---|
246 | $xpress_config->SettingValueWrite('update');
|
---|
247 | } else if (isset($_POST['export_d3f'])) {
|
---|
248 | $do_message = 'export(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
249 | $do_message .= wp_to_d3forum($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
250 | $do_message .= '....END';
|
---|
251 | } else if (isset($_POST['inport_d3f'])) {
|
---|
252 | $do_message = 'Import(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
253 | $do_message .= d3forum_to_wp($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
254 | $do_message .= '....END';
|
---|
255 | }
|
---|
256 |
|
---|
257 | $xpress_config->GroupeRoleCheck($blog_id);
|
---|
258 | echo '<div class="wrap">'."\n";
|
---|
259 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
260 | echo '<h2>' . __('XPressME Integration Setting', 'xpressme') . "</h2><br>\n";
|
---|
261 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
262 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
263 | echo '<table class="form-table">'."\n";
|
---|
264 | $upload_title = __('Media Upload Base Path','xpressme');
|
---|
265 | echo $xpress_config->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
266 | $upload_title,
|
---|
267 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
268 | __('USE WordPress BASE_PATH','xpressme'),
|
---|
269 | false
|
---|
270 | );
|
---|
271 | // $lock = ($xoops_config->module_url != get_bloginfo('url'));
|
---|
272 | $lock = false;
|
---|
273 | echo $xpress_config->groupe_role_option($lock);
|
---|
274 | echo $xpress_config->d3forum_option($do_message);
|
---|
275 | echo "</table>\n";
|
---|
276 |
|
---|
277 | echo '<p class="submit">'."\n";
|
---|
278 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
279 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
280 | echo "</p>\n";
|
---|
281 |
|
---|
282 | echo "</form>\n" ;
|
---|
283 | echo "</div>\n";
|
---|
284 | }
|
---|
285 |
|
---|
286 | function other_option_page()
|
---|
287 | {
|
---|
288 | global $xoops_config,$xpress_config;
|
---|
289 |
|
---|
290 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
291 |
|
---|
292 | $do_message ='';
|
---|
293 | if (!empty($_POST['submit_update'])) {
|
---|
294 | $xpress_config->ReadPostData($_POST);
|
---|
295 | $xpress_config->SettingValueWrite('update');
|
---|
296 | } else if (isset($_POST['submit_reset'])) {
|
---|
297 | $xpress_config->setDefault();
|
---|
298 | $xpress_config->SettingValueWrite('update');
|
---|
299 | }
|
---|
300 |
|
---|
301 | echo '<div class="wrap">'."\n";
|
---|
302 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
303 | echo '<h2>' . __('XPressME Other Setting', 'xpressme') . "</h2><br>\n";
|
---|
304 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
305 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
306 | echo '<table class="form-table">'."\n";
|
---|
307 | echo $xpress_config->yes_no_radio_option('is_save_post_revision',
|
---|
308 | __('The change tracking of the post is preserved','xpressme'),
|
---|
309 | __('YES','xpressme'),
|
---|
310 | __('NO','xpressme')
|
---|
311 | );
|
---|
312 |
|
---|
313 | echo $xpress_config->yes_no_radio_option('is_multi_user',
|
---|
314 | __('Select Multi user mode','xpressme'),
|
---|
315 | __('YES','xpressme'),
|
---|
316 | __('NO','xpressme')
|
---|
317 | );
|
---|
318 | echo $xpress_config->yes_no_radio_option('is_author_view_count',
|
---|
319 | __('Is the posts author views counted?','xpressme'),
|
---|
320 | __('YES','xpressme'),
|
---|
321 | __('NO','xpressme')
|
---|
322 | );
|
---|
323 | echo $xpress_config->header_meta_option();
|
---|
324 | echo $xpress_config->yes_no_radio_option('is_sql_debug',
|
---|
325 | __('Is SQL debugging window displayed?','xpressme'),
|
---|
326 | __('YES','xpressme'),
|
---|
327 | __('NO','xpressme')
|
---|
328 | );
|
---|
329 | echo $xpress_config->yes_no_radio_option('is_block_error_display',
|
---|
330 | __('Select warning display of block file version check','xpressme'),
|
---|
331 | __('Do display','xpressme'),
|
---|
332 | __('Do not display','xpressme')
|
---|
333 | );
|
---|
334 | echo "</table>\n";
|
---|
335 |
|
---|
336 | echo '<p class="submit">'."\n";
|
---|
337 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
338 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
339 | echo "</p>\n";
|
---|
340 |
|
---|
341 | echo "</form>\n" ;
|
---|
342 | echo "</div>\n";
|
---|
343 | }
|
---|
344 |
|
---|
345 | include_once dirname( __FILE__ ).'/include/xpress_upgrade.php' ;
|
---|
346 | add_action( 'admin_notices', 'xpress_update_check', 3 );
|
---|
347 |
|
---|
348 | include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ;
|
---|
349 | if(xpress_is_wp_version('>=','2.8')){
|
---|
350 | include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
|
---|
351 | }
|
---|
352 | ?> |
---|