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