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 | if($lang == 'ja_EUC'){
|
---|
73 | $blog_charset = get_option('blog_charset');
|
---|
74 | if ($blog_charset !=='EUC-JP') {
|
---|
75 | update_option('blog_charset', 'EUC-JP' );
|
---|
76 | }
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | add_action('admin_menu', 'my_plugin_menu');
|
---|
81 |
|
---|
82 | add_filter("upload_dir",array(&$xpress_config, 'xpress_upload_filter'), 1); // Change wp-include/wp_upload_dir()
|
---|
83 | if (!$xpress_config->is_save_post_revision){
|
---|
84 | remove_action( 'pre_post_update', 'wp_save_post_revision' ); // Not Save Post Revision
|
---|
85 | }
|
---|
86 | add_action("wp_meta" , "wp_meta_add_xpress_menu"); // add xpress menu in wp_meta
|
---|
87 |
|
---|
88 | //XOOPS Bloack Cache Refresh
|
---|
89 | add_action("comment_post", "block_cache_refresh");
|
---|
90 | add_action("edit_comment", "block_cache_refresh");
|
---|
91 | add_action("wp_set_comment_status","block_cache_refresh"); //wp_delete_comment() at deleted
|
---|
92 | add_action("deleted_post", "block_cache_refresh");
|
---|
93 | add_action("publish_post", "block_cache_refresh");
|
---|
94 | add_action("edit_post", "block_cache_refresh");
|
---|
95 | add_action("private_to_published", "block_cache_refresh");
|
---|
96 | add_action("transition_post_status", "block_cache_refresh");
|
---|
97 |
|
---|
98 | add_action("the_content", "set_post_views_count");
|
---|
99 |
|
---|
100 | // blog charset check
|
---|
101 | add_action("init", "blog_charset_check");
|
---|
102 |
|
---|
103 |
|
---|
104 | //XOOPS notifiction
|
---|
105 | require_once dirname( __FILE__ ).'/include/notify_functions.php' ;
|
---|
106 | add_action("transition_post_status", "onaction_publish_post_notify" ,10 , 3);
|
---|
107 | // add_action("edit_post", "onaction_edit_post_notify");
|
---|
108 | add_action("comment_post", "onaction_comment_notify");
|
---|
109 | // add_action("approve_comment" , "onaction_comment_apobe_notify");
|
---|
110 | add_action("wp_set_comment_status" , "onaction_comment_apobe_notify");
|
---|
111 |
|
---|
112 | // user data sync user_sync_to_xoops($user_id)
|
---|
113 | require_once dirname( __FILE__ ).'/include/user_sync_xoops.php' ;
|
---|
114 | add_action('profile_update', 'user_sync_to_xoops');
|
---|
115 | add_action('user_register', 'user_sync_to_xoops');
|
---|
116 | add_action('delete_blog', 'blog_group_role_delete',10,2); //at multi blog delete
|
---|
117 | add_action('wpmu_new_blog', 'blog_group_role_add',10,2); //at multi blog delete
|
---|
118 |
|
---|
119 | //require_once('../include/custom_functions.php');
|
---|
120 |
|
---|
121 | //D3Forum Comment Integration
|
---|
122 | if ($xpress_config->is_use_d3forum){
|
---|
123 | require_once dirname( __FILE__ ).'/include/d3forum_comment_synchro.php' ;
|
---|
124 | add_action("comment_post", "onaction_comment_post");
|
---|
125 | add_action("edit_comment", "onaction_edit_comment");
|
---|
126 | add_action("delete_comment","onaction_delete_comment");
|
---|
127 | add_action("delete_post", "onaction_delete_post");
|
---|
128 | add_action("wp_set_comment_status" , "onaction_comment_apobe");
|
---|
129 | add_action("publish_post", "onaction_comment_close");
|
---|
130 |
|
---|
131 | // comment trashed untrashed action
|
---|
132 | add_action("trashed_post_comments", "onaction_trashed_post_comments");
|
---|
133 | add_action("untrashed_post_comments", "onaction_untrashed_post_comments");
|
---|
134 | add_action("trashed_comment", "onaction_trashed_comment");
|
---|
135 | add_action("untrashed_comment", "onaction_untrashed_comment");
|
---|
136 |
|
---|
137 | add_filter('comments_template', "disp_d3forum_comments" );
|
---|
138 | }
|
---|
139 |
|
---|
140 | //The trackback and the pingback are excluded from the count of the comment.
|
---|
141 | add_filter('get_comments_number', 'xpress_comment_count', 0);
|
---|
142 |
|
---|
143 | // Query filter for MultiUser
|
---|
144 | add_filter('query','xpress_query_filter');
|
---|
145 | //add_action("init", "xpress_set_author_cookie");
|
---|
146 | if(xpress_is_wp_version('<','2.1')){
|
---|
147 | // It is called before parse_request() makes $GET.
|
---|
148 | add_action("query_vars", "xpress_set_author_cookie");
|
---|
149 | } else {
|
---|
150 | // It is called at the end of parse_request().
|
---|
151 | add_filter('request', 'xpress_set_author_cookie');
|
---|
152 | }
|
---|
153 |
|
---|
154 | // SQL debug windows
|
---|
155 | add_filter('query', array(&$xpress_config, 'xpress_sql_debug'));
|
---|
156 | add_action('admin_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
157 | add_action('wp_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
158 |
|
---|
159 | // Multi Blog default Themes
|
---|
160 | function my_new_blog_template($blog_id) {
|
---|
161 | $default_theme = 'xpress_default';
|
---|
162 | update_blog_option($blog_id, 'template',$default_theme);
|
---|
163 | update_blog_option($blog_id, 'stylesheet', $default_theme);
|
---|
164 | }
|
---|
165 | add_action('wpmu_new_blog','my_new_blog_template',0,1);
|
---|
166 |
|
---|
167 | function redirect_xoops_admin()
|
---|
168 | {
|
---|
169 | global $xoops_config,$xpress_config;
|
---|
170 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
171 | wp_redirect($xoops_admin_url);
|
---|
172 | }
|
---|
173 |
|
---|
174 | function display_option_page()
|
---|
175 | {
|
---|
176 | global $xoops_config,$xpress_config;
|
---|
177 |
|
---|
178 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
179 |
|
---|
180 | $do_message ='';
|
---|
181 | if (!empty($_POST['submit_update'])) {
|
---|
182 | $xpress_config->ReadPostData($_POST);
|
---|
183 | $xpress_config->SettingValueWrite('update');
|
---|
184 | } else if (isset($_POST['submit_reset'])) {
|
---|
185 | $xpress_config->setDefault();
|
---|
186 | $xpress_config->SettingValueWrite('update');
|
---|
187 | }
|
---|
188 |
|
---|
189 | echo '<div class="wrap">'."\n";
|
---|
190 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
191 | echo '<h2>' . __('XPressME Display Setting', 'xpressme') . "</h2><br>\n";
|
---|
192 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
193 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
194 | echo '<table class="form-table">'."\n";
|
---|
195 | echo $xpress_config->viewer_type_option();
|
---|
196 | echo $xpress_config->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
197 | __('Thema Sidebar Display','xpressme'),
|
---|
198 | __('YES','xpressme'),
|
---|
199 | __('NO','xpressme')
|
---|
200 | );
|
---|
201 | echo $xpress_config->single_post_navi_option();
|
---|
202 | echo $xpress_config->posts_page_navi_option();
|
---|
203 | echo $xpress_config->excerpt_option();
|
---|
204 | echo $xpress_config->dashboard_display_option();
|
---|
205 | echo "</table>\n";
|
---|
206 |
|
---|
207 | echo '<p class="submit">'."\n";
|
---|
208 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
209 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
210 | echo "</p>\n";
|
---|
211 |
|
---|
212 | echo "</form>\n" ;
|
---|
213 | echo "</div>\n";
|
---|
214 | }
|
---|
215 |
|
---|
216 | function integration_option_page()
|
---|
217 | {
|
---|
218 | global $xoops_config,$xpress_config,$blog_id;
|
---|
219 |
|
---|
220 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
221 |
|
---|
222 | $do_message ='';
|
---|
223 | if (!empty($_POST['submit_update'])) {
|
---|
224 | $xpress_config->ReadPostData($_POST);
|
---|
225 | $xpress_config->SettingValueWrite('update');
|
---|
226 | } else if (isset($_POST['submit_reset'])) {
|
---|
227 | $xpress_config->setDefault();
|
---|
228 | $xpress_config->SettingValueWrite('update');
|
---|
229 | } else if (isset($_POST['export_d3f'])) {
|
---|
230 | $do_message = 'export(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
231 | $do_message .= wp_to_d3forum($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
232 | $do_message .= '....END';
|
---|
233 | } else if (isset($_POST['inport_d3f'])) {
|
---|
234 | $do_message = 'Import(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
235 | $do_message .= d3forum_to_wp($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
236 | $do_message .= '....END';
|
---|
237 | }
|
---|
238 |
|
---|
239 | $xpress_config->GroupeRoleCheck($blog_id);
|
---|
240 | echo '<div class="wrap">'."\n";
|
---|
241 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
242 | echo '<h2>' . __('XPressME Integration Setting', 'xpressme') . "</h2><br>\n";
|
---|
243 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
244 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
245 | echo '<table class="form-table">'."\n";
|
---|
246 | $upload_title = __('Media Upload Base Path','xpressme');
|
---|
247 | echo $xpress_config->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
248 | $upload_title,
|
---|
249 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
250 | __('USE WordPress BASE_PATH','xpressme'),
|
---|
251 | false
|
---|
252 | );
|
---|
253 | // $lock = ($xoops_config->module_url != get_bloginfo('url'));
|
---|
254 | $lock = false;
|
---|
255 | echo $xpress_config->groupe_role_option($lock);
|
---|
256 | echo $xpress_config->d3forum_option($do_message);
|
---|
257 | echo "</table>\n";
|
---|
258 |
|
---|
259 | echo '<p class="submit">'."\n";
|
---|
260 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
261 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
262 | echo "</p>\n";
|
---|
263 |
|
---|
264 | echo "</form>\n" ;
|
---|
265 | echo "</div>\n";
|
---|
266 | }
|
---|
267 |
|
---|
268 | function other_option_page()
|
---|
269 | {
|
---|
270 | global $xoops_config,$xpress_config;
|
---|
271 |
|
---|
272 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
273 |
|
---|
274 | $do_message ='';
|
---|
275 | if (!empty($_POST['submit_update'])) {
|
---|
276 | $xpress_config->ReadPostData($_POST);
|
---|
277 | $xpress_config->SettingValueWrite('update');
|
---|
278 | } else if (isset($_POST['submit_reset'])) {
|
---|
279 | $xpress_config->setDefault();
|
---|
280 | $xpress_config->SettingValueWrite('update');
|
---|
281 | }
|
---|
282 |
|
---|
283 | echo '<div class="wrap">'."\n";
|
---|
284 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
285 | echo '<h2>' . __('XPressME Other Setting', 'xpressme') . "</h2><br>\n";
|
---|
286 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
287 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
288 | echo '<table class="form-table">'."\n";
|
---|
289 | echo $xpress_config->yes_no_radio_option('is_save_post_revision',
|
---|
290 | __('The change tracking of the post is preserved','xpressme'),
|
---|
291 | __('YES','xpressme'),
|
---|
292 | __('NO','xpressme')
|
---|
293 | );
|
---|
294 |
|
---|
295 | echo $xpress_config->yes_no_radio_option('is_multi_user',
|
---|
296 | __('Select Multi user mode','xpressme'),
|
---|
297 | __('YES','xpressme'),
|
---|
298 | __('NO','xpressme')
|
---|
299 | );
|
---|
300 | echo $xpress_config->yes_no_radio_option('is_author_view_count',
|
---|
301 | __('Is the posts author views counted?','xpressme'),
|
---|
302 | __('YES','xpressme'),
|
---|
303 | __('NO','xpressme')
|
---|
304 | );
|
---|
305 | echo $xpress_config->header_meta_option();
|
---|
306 | echo $xpress_config->yes_no_radio_option('is_sql_debug',
|
---|
307 | __('Is SQL debugging window displayed?','xpressme'),
|
---|
308 | __('YES','xpressme'),
|
---|
309 | __('NO','xpressme')
|
---|
310 | );
|
---|
311 | echo $xpress_config->yes_no_radio_option('is_block_error_display',
|
---|
312 | __('Select warning display of block file version check','xpressme'),
|
---|
313 | __('Do display','xpressme'),
|
---|
314 | __('Do not display','xpressme')
|
---|
315 | );
|
---|
316 | echo "</table>\n";
|
---|
317 |
|
---|
318 | echo '<p class="submit">'."\n";
|
---|
319 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
320 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
321 | echo "</p>\n";
|
---|
322 |
|
---|
323 | echo "</form>\n" ;
|
---|
324 | echo "</div>\n";
|
---|
325 | }
|
---|
326 |
|
---|
327 | include_once dirname( __FILE__ ).'/include/xpress_upgrade.php' ;
|
---|
328 | add_action( 'admin_notices', 'xpress_update_check', 3 );
|
---|
329 |
|
---|
330 | include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ;
|
---|
331 | if(xpress_is_wp_version('>=','2.8')){
|
---|
332 | include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
|
---|
333 | }
|
---|
334 | ?> |
---|