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 | function my_plugin_menu()
|
---|
25 | {
|
---|
26 | global $xpress_config,$xoops_config;
|
---|
27 |
|
---|
28 | $plugin_url = WP_PLUGIN_URL."/xpressme/";
|
---|
29 |
|
---|
30 | // Add a new top-level menu:
|
---|
31 | add_menu_page('XPressME','XPressME', 8, __FILE__, 'display_option_page' , $plugin_url.'/images/menu_icon.png');
|
---|
32 | // Add submenus to the custom top-level menu:
|
---|
33 | add_submenu_page(__FILE__, __('Display Settings', 'xpressme'), __('Display Settings', 'xpressme'), 8, __FILE__, 'display_option_page');
|
---|
34 | add_submenu_page(__FILE__, __('Integration Settings', 'xpressme'), __('Integration Settings', 'xpressme'), 8, 'integration_option_page', 'integration_option_page');
|
---|
35 | add_submenu_page(__FILE__, __('Other Settings', 'xpressme'), __('Other Settings', 'xpressme'), 8, 'other_option_page', 'other_option_page');
|
---|
36 | add_submenu_page(__FILE__, __('to XOOPS Admin', 'xpressme'), __('to XOOPS Admin', 'xpressme'), 8, 'redirect_xoops_admin', 'redirect_xoops_admin');
|
---|
37 | }
|
---|
38 | add_action('admin_menu', 'my_plugin_menu');
|
---|
39 |
|
---|
40 | add_filter("upload_dir",array(&$xpress_config, 'xpress_upload_filter'), 1); // Change wp-include/wp_upload_dir()
|
---|
41 | if (!$xpress_config->is_save_post_revision){
|
---|
42 | remove_action( 'pre_post_update', 'wp_save_post_revision' ); // Not Save Post Revision
|
---|
43 | }
|
---|
44 | add_action("wp_meta" , "wp_meta_add_xpress_menu"); // add xpress menu in wp_meta
|
---|
45 |
|
---|
46 | //Site URL check
|
---|
47 | add_filter('option_home', "safe_site_url_filter");
|
---|
48 | add_filter('option_siteurl', "safe_site_url_filter");
|
---|
49 |
|
---|
50 |
|
---|
51 | //XOOPS Bloack Cache Refresh
|
---|
52 | add_action("comment_post", "block_cache_refresh");
|
---|
53 | add_action("edit_comment", "block_cache_refresh");
|
---|
54 | add_action("wp_set_comment_status","block_cache_refresh"); //wp_delete_comment() at deleted
|
---|
55 | add_action("deleted_post", "block_cache_refresh");
|
---|
56 | add_action("publish_post", "block_cache_refresh");
|
---|
57 | add_action("edit_post", "block_cache_refresh");
|
---|
58 | add_action("private_to_published", "block_cache_refresh");
|
---|
59 | add_action("transition_post_status", "block_cache_refresh");
|
---|
60 |
|
---|
61 | add_action("the_content", "set_post_views_count");
|
---|
62 |
|
---|
63 | //XOOPS notifiction
|
---|
64 | require_once dirname( __FILE__ ).'/include/notify_functions.php' ;
|
---|
65 | add_action("transition_post_status", "onaction_publish_post_notify" ,10 , 3);
|
---|
66 | // add_action("edit_post", "onaction_edit_post_notify");
|
---|
67 | add_action("comment_post", "onaction_comment_notify");
|
---|
68 | // add_action("approve_comment" , "onaction_comment_apobe_notify");
|
---|
69 | add_action("wp_set_comment_status" , "onaction_comment_apobe_notify");
|
---|
70 |
|
---|
71 | // user data sync user_sync_to_xoops($user_id)
|
---|
72 | require_once dirname( __FILE__ ).'/include/user_sync_xoops.php' ;
|
---|
73 | add_action('profile_update', 'user_sync_to_xoops');
|
---|
74 | add_action('user_register', 'user_sync_to_xoops');
|
---|
75 | //require_once('../include/custom_functions.php');
|
---|
76 |
|
---|
77 | //D3Forum Comment Integration
|
---|
78 | if ($xpress_config->is_use_d3forum){
|
---|
79 | require_once dirname( __FILE__ ).'/include/d3forum_comment_synchro.php' ;
|
---|
80 | add_action("comment_post", "onaction_comment_post");
|
---|
81 | add_action("edit_comment", "onaction_edit_comment");
|
---|
82 | add_action("delete_comment","onaction_delete_comment");
|
---|
83 | add_action("delete_post", "onaction_delete_post");
|
---|
84 | add_action("wp_set_comment_status" , "onaction_comment_apobe");
|
---|
85 |
|
---|
86 |
|
---|
87 | add_filter('comments_template', "disp_d3forum_comments" );
|
---|
88 |
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | //The trackback and the pingback are excluded from the count of the comment.
|
---|
94 | add_filter('get_comments_number', 'xpress_comment_count', 0);
|
---|
95 |
|
---|
96 | // Query filter for MultiUser
|
---|
97 | add_filter('query','xpress_query_filter');
|
---|
98 | //add_action("init", "xpress_set_author_cookie");
|
---|
99 | if(xpress_is_wp_version('<','2.1')){
|
---|
100 | // It is called before parse_request() makes $GET.
|
---|
101 | add_action("query_vars", "xpress_set_author_cookie");
|
---|
102 | } else {
|
---|
103 | // It is called at the end of parse_request().
|
---|
104 | add_filter('request', 'xpress_set_author_cookie');
|
---|
105 | }
|
---|
106 |
|
---|
107 | // SQL debug windows
|
---|
108 | add_filter('query', array(&$xpress_config, 'xpress_sql_debug'));
|
---|
109 | add_action('admin_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
110 | add_action('wp_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
111 |
|
---|
112 | function redirect_xoops_admin()
|
---|
113 | {
|
---|
114 | global $xoops_config,$xpress_config;
|
---|
115 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
116 | wp_redirect($xoops_admin_url);
|
---|
117 | }
|
---|
118 |
|
---|
119 | function display_option_page()
|
---|
120 | {
|
---|
121 | global $xoops_config,$xpress_config;
|
---|
122 |
|
---|
123 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
124 |
|
---|
125 | $do_message ='';
|
---|
126 | if (!empty($_POST['submit_update'])) {
|
---|
127 | $xpress_config->ReadPostData($_POST);
|
---|
128 | $xpress_config->SettingValueWrite('update');
|
---|
129 | } else if (isset($_POST['submit_reset'])) {
|
---|
130 | $xpress_config->setDefault();
|
---|
131 | $xpress_config->SettingValueWrite('update');
|
---|
132 | }
|
---|
133 |
|
---|
134 | echo '<div class="wrap">'."\n";
|
---|
135 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
136 | echo '<h2>' . __('XPressME Display Setting', 'xpressme') . "</h2><br>\n";
|
---|
137 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
138 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
139 | echo '<table class="form-table">'."\n";
|
---|
140 | echo $xpress_config->viewer_type_option();
|
---|
141 | echo $xpress_config->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
142 | __('Thema Sidebar Display','xpressme'),
|
---|
143 | __('YES','xpressme'),
|
---|
144 | __('NO','xpressme')
|
---|
145 | );
|
---|
146 | echo $xpress_config->single_post_navi_option();
|
---|
147 | echo $xpress_config->posts_page_navi_option();
|
---|
148 | echo $xpress_config->excerpt_option();
|
---|
149 | echo "</table>\n";
|
---|
150 |
|
---|
151 | echo '<p class="submit">'."\n";
|
---|
152 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
153 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
154 | echo "</p>\n";
|
---|
155 |
|
---|
156 | echo "</form>\n" ;
|
---|
157 | echo "</div>\n";
|
---|
158 | }
|
---|
159 |
|
---|
160 | function integration_option_page()
|
---|
161 | {
|
---|
162 | global $xoops_config,$xpress_config;
|
---|
163 |
|
---|
164 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
165 |
|
---|
166 | $do_message ='';
|
---|
167 | if (!empty($_POST['submit_update'])) {
|
---|
168 | $xpress_config->ReadPostData($_POST);
|
---|
169 | $xpress_config->SettingValueWrite('update');
|
---|
170 | } else if (isset($_POST['submit_reset'])) {
|
---|
171 | $xpress_config->setDefault();
|
---|
172 | $xpress_config->SettingValueWrite('update');
|
---|
173 | } else if (isset($_POST['export_d3f'])) {
|
---|
174 | $do_message = 'export(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
175 | $do_message .= wp_to_d3forum($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
176 | $do_message .= '....END';
|
---|
177 | } else if (isset($_POST['inport_d3f'])) {
|
---|
178 | $do_message = 'Import(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
179 | $do_message .= d3forum_to_wp($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
180 | $do_message .= '....END';
|
---|
181 | }
|
---|
182 |
|
---|
183 | echo '<div class="wrap">'."\n";
|
---|
184 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
185 | echo '<h2>' . __('XPressME Integration Setting', 'xpressme') . "</h2><br>\n";
|
---|
186 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
187 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
188 | echo '<table class="form-table">'."\n";
|
---|
189 | echo $xpress_config->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
190 | __('Media Upload Base Path','xpressme'),
|
---|
191 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
192 | __('USE WordPress BASE_PATH','xpressme')
|
---|
193 | );
|
---|
194 |
|
---|
195 | echo $xpress_config->groupe_role_option();
|
---|
196 |
|
---|
197 | echo $xpress_config->d3forum_option($do_message);
|
---|
198 | echo "</table>\n";
|
---|
199 |
|
---|
200 | echo '<p class="submit">'."\n";
|
---|
201 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
202 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
203 | echo "</p>\n";
|
---|
204 |
|
---|
205 | echo "</form>\n" ;
|
---|
206 | echo "</div>\n";
|
---|
207 | }
|
---|
208 |
|
---|
209 | function other_option_page()
|
---|
210 | {
|
---|
211 | global $xoops_config,$xpress_config;
|
---|
212 |
|
---|
213 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
214 |
|
---|
215 | $do_message ='';
|
---|
216 | if (!empty($_POST['submit_update'])) {
|
---|
217 | $xpress_config->ReadPostData($_POST);
|
---|
218 | $xpress_config->SettingValueWrite('update');
|
---|
219 | } else if (isset($_POST['submit_reset'])) {
|
---|
220 | $xpress_config->setDefault();
|
---|
221 | $xpress_config->SettingValueWrite('update');
|
---|
222 | }
|
---|
223 |
|
---|
224 | echo '<div class="wrap">'."\n";
|
---|
225 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
226 | echo '<h2>' . __('XPressME Other Setting', 'xpressme') . "</h2><br>\n";
|
---|
227 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
228 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
229 | echo '<table class="form-table">'."\n";
|
---|
230 | echo $xpress_config->yes_no_radio_option('is_save_post_revision',
|
---|
231 | __('The change tracking of the post is preserved','xpressme'),
|
---|
232 | __('YES','xpressme'),
|
---|
233 | __('NO','xpressme')
|
---|
234 | );
|
---|
235 |
|
---|
236 | echo $xpress_config->yes_no_radio_option('is_multi_user',
|
---|
237 | __('Select Multi user mode','xpressme'),
|
---|
238 | __('YES','xpressme'),
|
---|
239 | __('NO','xpressme')
|
---|
240 | );
|
---|
241 | echo $xpress_config->yes_no_radio_option('is_author_view_count',
|
---|
242 | __('Is the posts author views counted?','xpressme'),
|
---|
243 | __('YES','xpressme'),
|
---|
244 | __('NO','xpressme')
|
---|
245 | );
|
---|
246 | echo $xpress_config->header_meta_option();
|
---|
247 | echo $xpress_config->yes_no_radio_option('is_sql_debug',
|
---|
248 | __('Is SQL debugging window displayed?','xpressme'),
|
---|
249 | __('YES','xpressme'),
|
---|
250 | __('NO','xpressme')
|
---|
251 | );
|
---|
252 | echo "</table>\n";
|
---|
253 |
|
---|
254 | echo '<p class="submit">'."\n";
|
---|
255 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
256 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
257 | echo "</p>\n";
|
---|
258 |
|
---|
259 | echo "</form>\n" ;
|
---|
260 | echo "</div>\n";
|
---|
261 | }
|
---|
262 |
|
---|
263 | ?> |
---|