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