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