XPressME Integration Kit

Trac

source: trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php @ 518

Last change on this file since 518 was 518, checked in by toemon, 14 years ago

グループ権限割り当てがリセットされてしまうバグの修正 #289

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