[18] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | Plugin Name: Plugin for XPressME
|
---|
[193] | 4 | Plugin URI: http://ja.xpressme.info
|
---|
[18] | 5 | Description: Plugin for XPressME (custom function,filter,action)
|
---|
| 6 | Author: toemon
|
---|
[193] | 7 | Version: 1.0
|
---|
| 8 | Author URI: http://ja.xpressme.info
|
---|
[18] | 9 | */
|
---|
[19] | 10 | require_once('xpressme_class.php');
|
---|
[75] | 11 |
|
---|
[95] | 12 | require_once dirname( __FILE__ ).'/include/custom_functions.php' ; // XPressME functions for themes
|
---|
| 13 | require_once dirname( __FILE__ ).'/include/xpress_common_functions.php' ;
|
---|
[46] | 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 |
|
---|
[144] | 19 | $xpress_config = new XPressME_Class();
|
---|
[83] | 20 |
|
---|
| 21 | require_once dirname( __FILE__ ).'/include/pluggable-override.php' ;
|
---|
[360] | 22 | require_once dirname( __FILE__ ).'/include/functions_for_wp_old.php' ;
|
---|
[83] | 23 |
|
---|
[812] | 24 | if (!is_wordpress_style()
|
---|
| 25 | && ( !empty($xpress_config->theme_select) || $xpress_config->theme_select != 'use_wordpress_select')
|
---|
| 26 | && !is_buddypress_active()
|
---|
| 27 | ){
|
---|
[392] | 28 | add_filter('stylesheet', 'xpress_Stylesheet');
|
---|
| 29 | add_filter('template', 'xpress_ThemeTemplate');
|
---|
| 30 | }
|
---|
| 31 | function xpress_Stylesheet($stylesheet) {
|
---|
| 32 | global $xpress_config;
|
---|
| 33 | $theme = $xpress_config->theme_select;
|
---|
| 34 | $theme = get_theme($theme);
|
---|
| 35 |
|
---|
| 36 | if (empty($theme)) {
|
---|
| 37 | return $stylesheet;
|
---|
| 38 | }
|
---|
| 39 | return $theme['Stylesheet'];
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | function xpress_ThemeTemplate($template) {
|
---|
| 43 | global $xpress_config;
|
---|
| 44 | $theme = $xpress_config->theme_select;
|
---|
| 45 | $theme = get_theme($theme);
|
---|
| 46 |
|
---|
| 47 | if (empty($theme)) {
|
---|
| 48 | return $template;
|
---|
| 49 | }
|
---|
| 50 | return $theme['Template'];
|
---|
| 51 | }
|
---|
| 52 |
|
---|
[302] | 53 | function my_plugin_menu()
|
---|
| 54 | {
|
---|
[328] | 55 | global $xpress_config,$xoops_config;
|
---|
| 56 |
|
---|
[311] | 57 | $plugin_url = WP_PLUGIN_URL."/xpressme/";
|
---|
| 58 |
|
---|
[328] | 59 | // Add a new top-level menu:
|
---|
| 60 | add_menu_page('XPressME','XPressME', 8, __FILE__, 'display_option_page' , $plugin_url.'/images/menu_icon.png');
|
---|
| 61 | // Add submenus to the custom top-level menu:
|
---|
| 62 | add_submenu_page(__FILE__, __('Display Settings', 'xpressme'), __('Display Settings', 'xpressme'), 8, __FILE__, 'display_option_page');
|
---|
| 63 | add_submenu_page(__FILE__, __('Integration Settings', 'xpressme'), __('Integration Settings', 'xpressme'), 8, 'integration_option_page', 'integration_option_page');
|
---|
| 64 | add_submenu_page(__FILE__, __('Other Settings', 'xpressme'), __('Other Settings', 'xpressme'), 8, 'other_option_page', 'other_option_page');
|
---|
[370] | 65 | // if (function_exists('wp_remote_get'))
|
---|
[568] | 66 | if(!xpress_is_multiblog() || xpress_is_multiblog_root()){
|
---|
[368] | 67 | add_submenu_page(__FILE__, __('Upgrade', 'xpressme'), __('Upgrade', 'xpressme'), 8, 'upgrade_page', 'upgrade_page');
|
---|
[566] | 68 | add_submenu_page(__FILE__, __('to Modules Admin', 'xpressme'), __('to Modules Admin', 'xpressme'), 8, 'redirect_xoops_admin', 'redirect_xoops_admin');
|
---|
| 69 | }
|
---|
[302] | 70 | }
|
---|
[584] | 71 |
|
---|
| 72 | function blog_charset_check()
|
---|
| 73 | {
|
---|
| 74 | $lang= WPLANG;
|
---|
[633] | 75 | $blog_charset = get_option('blog_charset');
|
---|
| 76 | switch ($lang) {
|
---|
| 77 | case 'ja_EUC':
|
---|
| 78 | if ($blog_charset !=='EUC-JP') update_option('blog_charset', 'EUC-JP' );
|
---|
| 79 | break;
|
---|
| 80 | case 'ja_UTF':
|
---|
| 81 | case 'ja':
|
---|
| 82 | if ($blog_charset !=='UTF-8') update_option('blog_charset', 'UTF-8' );
|
---|
| 83 | break;
|
---|
| 84 | default:
|
---|
| 85 | }
|
---|
[584] | 86 | }
|
---|
| 87 |
|
---|
[794] | 88 | // enable multibyte username
|
---|
[797] | 89 | if( ! function_exists( 'sanitize_user_multibyte_at_update' ) ){
|
---|
| 90 | function sanitize_user_multibyte_at_update($username, $raw_username, $strict){
|
---|
| 91 | if (isset($_POST['action']) && $_POST['action'] == 'update'){
|
---|
| 92 | if ($raw_username !== "" && $username !== $raw_username){
|
---|
| 93 | return $raw_username;
|
---|
| 94 | }
|
---|
[794] | 95 | }
|
---|
[797] | 96 | return $username;
|
---|
[794] | 97 | }
|
---|
| 98 | }
|
---|
[797] | 99 | add_filter('sanitize_user', "sanitize_user_multibyte_at_update" ,10,3);
|
---|
[794] | 100 |
|
---|
[302] | 101 | add_action('admin_menu', 'my_plugin_menu');
|
---|
| 102 |
|
---|
[144] | 103 | add_filter("upload_dir",array(&$xpress_config, 'xpress_upload_filter'), 1); // Change wp-include/wp_upload_dir()
|
---|
| 104 | if (!$xpress_config->is_save_post_revision){
|
---|
[28] | 105 | remove_action( 'pre_post_update', 'wp_save_post_revision' ); // Not Save Post Revision
|
---|
| 106 | }
|
---|
[145] | 107 | add_action("wp_meta" , "wp_meta_add_xpress_menu"); // add xpress menu in wp_meta
|
---|
[96] | 108 |
|
---|
| 109 | //XOOPS Bloack Cache Refresh
|
---|
[46] | 110 | add_action("comment_post", "block_cache_refresh");
|
---|
| 111 | add_action("edit_comment", "block_cache_refresh");
|
---|
[96] | 112 | add_action("wp_set_comment_status","block_cache_refresh"); //wp_delete_comment() at deleted
|
---|
| 113 | add_action("deleted_post", "block_cache_refresh");
|
---|
[46] | 114 | add_action("publish_post", "block_cache_refresh");
|
---|
| 115 | add_action("edit_post", "block_cache_refresh");
|
---|
| 116 | add_action("private_to_published", "block_cache_refresh");
|
---|
[96] | 117 | add_action("transition_post_status", "block_cache_refresh");
|
---|
[46] | 118 |
|
---|
[51] | 119 | add_action("the_content", "set_post_views_count");
|
---|
| 120 |
|
---|
[584] | 121 | // blog charset check
|
---|
| 122 | add_action("init", "blog_charset_check");
|
---|
| 123 |
|
---|
| 124 |
|
---|
[61] | 125 | //XOOPS notifiction
|
---|
| 126 | require_once dirname( __FILE__ ).'/include/notify_functions.php' ;
|
---|
[91] | 127 | add_action("transition_post_status", "onaction_publish_post_notify" ,10 , 3);
|
---|
[61] | 128 | // add_action("edit_post", "onaction_edit_post_notify");
|
---|
| 129 | add_action("comment_post", "onaction_comment_notify");
|
---|
| 130 | // add_action("approve_comment" , "onaction_comment_apobe_notify");
|
---|
| 131 | add_action("wp_set_comment_status" , "onaction_comment_apobe_notify");
|
---|
[51] | 132 |
|
---|
[72] | 133 | // user data sync user_sync_to_xoops($user_id)
|
---|
| 134 | require_once dirname( __FILE__ ).'/include/user_sync_xoops.php' ;
|
---|
| 135 | add_action('profile_update', 'user_sync_to_xoops');
|
---|
| 136 | add_action('user_register', 'user_sync_to_xoops');
|
---|
[534] | 137 | add_action('delete_blog', 'blog_group_role_delete',10,2); //at multi blog delete
|
---|
| 138 | add_action('wpmu_new_blog', 'blog_group_role_add',10,2); //at multi blog delete
|
---|
| 139 |
|
---|
[32] | 140 | //require_once('../include/custom_functions.php');
|
---|
[88] | 141 |
|
---|
[104] | 142 | //D3Forum Comment Integration
|
---|
[144] | 143 | if ($xpress_config->is_use_d3forum){
|
---|
[104] | 144 | require_once dirname( __FILE__ ).'/include/d3forum_comment_synchro.php' ;
|
---|
| 145 | add_action("comment_post", "onaction_comment_post");
|
---|
| 146 | add_action("edit_comment", "onaction_edit_comment");
|
---|
| 147 | add_action("delete_comment","onaction_delete_comment");
|
---|
| 148 | add_action("delete_post", "onaction_delete_post");
|
---|
| 149 | add_action("wp_set_comment_status" , "onaction_comment_apobe");
|
---|
[596] | 150 | add_action("publish_post", "onaction_comment_close");
|
---|
[597] | 151 |
|
---|
| 152 | // comment trashed untrashed action
|
---|
| 153 | add_action("trashed_post_comments", "onaction_trashed_post_comments");
|
---|
| 154 | add_action("untrashed_post_comments", "onaction_untrashed_post_comments");
|
---|
| 155 | add_action("trashed_comment", "onaction_trashed_comment");
|
---|
| 156 | add_action("untrashed_comment", "onaction_untrashed_comment");
|
---|
[596] | 157 |
|
---|
[104] | 158 | add_filter('comments_template', "disp_d3forum_comments" );
|
---|
| 159 | }
|
---|
| 160 |
|
---|
[147] | 161 | //The trackback and the pingback are excluded from the count of the comment.
|
---|
| 162 | add_filter('get_comments_number', 'xpress_comment_count', 0);
|
---|
[104] | 163 |
|
---|
[155] | 164 | // Query filter for MultiUser
|
---|
| 165 | add_filter('query','xpress_query_filter');
|
---|
[236] | 166 | //add_action("init", "xpress_set_author_cookie");
|
---|
[360] | 167 | if(xpress_is_wp_version('<','2.1')){
|
---|
[281] | 168 | // It is called before parse_request() makes $GET.
|
---|
| 169 | add_action("query_vars", "xpress_set_author_cookie");
|
---|
| 170 | } else {
|
---|
| 171 | // It is called at the end of parse_request().
|
---|
| 172 | add_filter('request', 'xpress_set_author_cookie');
|
---|
| 173 | }
|
---|
[155] | 174 |
|
---|
[88] | 175 | // SQL debug windows
|
---|
[144] | 176 | add_filter('query', array(&$xpress_config, 'xpress_sql_debug'));
|
---|
| 177 | add_action('admin_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
[280] | 178 | add_action('wp_footer', array(&$xpress_config, 'displayDebugLog'));
|
---|
| 179 |
|
---|
[532] | 180 | // Multi Blog default Themes
|
---|
| 181 | function my_new_blog_template($blog_id) {
|
---|
| 182 | $default_theme = 'xpress_default';
|
---|
| 183 | update_blog_option($blog_id, 'template',$default_theme);
|
---|
| 184 | update_blog_option($blog_id, 'stylesheet', $default_theme);
|
---|
| 185 | }
|
---|
| 186 | add_action('wpmu_new_blog','my_new_blog_template',0,1);
|
---|
| 187 |
|
---|
[349] | 188 | function redirect_xoops_admin()
|
---|
| 189 | {
|
---|
| 190 | global $xoops_config,$xpress_config;
|
---|
| 191 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
| 192 | wp_redirect($xoops_admin_url);
|
---|
| 193 | }
|
---|
[328] | 194 |
|
---|
| 195 | function display_option_page()
|
---|
| 196 | {
|
---|
| 197 | global $xoops_config,$xpress_config;
|
---|
| 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 | }
|
---|
| 209 |
|
---|
| 210 | echo '<div class="wrap">'."\n";
|
---|
| 211 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
[332] | 212 | echo '<h2>' . __('XPressME Display Setting', 'xpressme') . "</h2><br>\n";
|
---|
[349] | 213 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
[328] | 214 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 215 | echo '<table class="form-table">'."\n";
|
---|
| 216 | echo $xpress_config->viewer_type_option();
|
---|
| 217 | echo $xpress_config->yes_no_radio_option('is_theme_sidebar_disp',
|
---|
| 218 | __('Thema Sidebar Display','xpressme'),
|
---|
| 219 | __('YES','xpressme'),
|
---|
| 220 | __('NO','xpressme')
|
---|
| 221 | );
|
---|
| 222 | echo $xpress_config->single_post_navi_option();
|
---|
| 223 | echo $xpress_config->posts_page_navi_option();
|
---|
| 224 | echo $xpress_config->excerpt_option();
|
---|
[379] | 225 | echo $xpress_config->dashboard_display_option();
|
---|
[328] | 226 | echo "</table>\n";
|
---|
| 227 |
|
---|
| 228 | echo '<p class="submit">'."\n";
|
---|
| 229 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 230 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 231 | echo "</p>\n";
|
---|
| 232 |
|
---|
| 233 | echo "</form>\n" ;
|
---|
| 234 | echo "</div>\n";
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | function integration_option_page()
|
---|
| 238 | {
|
---|
[534] | 239 | global $xoops_config,$xpress_config,$blog_id;
|
---|
[328] | 240 |
|
---|
| 241 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
| 242 |
|
---|
| 243 | $do_message ='';
|
---|
| 244 | if (!empty($_POST['submit_update'])) {
|
---|
| 245 | $xpress_config->ReadPostData($_POST);
|
---|
| 246 | $xpress_config->SettingValueWrite('update');
|
---|
| 247 | } else if (isset($_POST['submit_reset'])) {
|
---|
| 248 | $xpress_config->setDefault();
|
---|
| 249 | $xpress_config->SettingValueWrite('update');
|
---|
| 250 | } else if (isset($_POST['export_d3f'])) {
|
---|
| 251 | $do_message = 'export(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
| 252 | $do_message .= wp_to_d3forum($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
| 253 | $do_message .= '....END';
|
---|
| 254 | } else if (isset($_POST['inport_d3f'])) {
|
---|
| 255 | $do_message = 'Import(' . $xpress_config->d3forum_module_dir . '--ID=' . $xpress_config->d3forum_forum_id . ')................';
|
---|
| 256 | $do_message .= d3forum_to_wp($xpress_config->d3forum_forum_id, $xpress_config->d3forum_module_dir);
|
---|
| 257 | $do_message .= '....END';
|
---|
| 258 | }
|
---|
| 259 |
|
---|
[534] | 260 | $xpress_config->GroupeRoleCheck($blog_id);
|
---|
[328] | 261 | echo '<div class="wrap">'."\n";
|
---|
| 262 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
[332] | 263 | echo '<h2>' . __('XPressME Integration Setting', 'xpressme') . "</h2><br>\n";
|
---|
[349] | 264 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
[328] | 265 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 266 | echo '<table class="form-table">'."\n";
|
---|
[402] | 267 | $upload_title = __('Media Upload Base Path','xpressme');
|
---|
[328] | 268 | echo $xpress_config->yes_no_radio_option('is_use_xoops_upload_path',
|
---|
[563] | 269 | $upload_title,
|
---|
| 270 | __('Use XOOPS UPLOAD PATH','xpressme'),
|
---|
| 271 | __('USE WordPress BASE_PATH','xpressme'),
|
---|
| 272 | false
|
---|
| 273 | );
|
---|
[534] | 274 | // $lock = ($xoops_config->module_url != get_bloginfo('url'));
|
---|
| 275 | $lock = false;
|
---|
[404] | 276 | echo $xpress_config->groupe_role_option($lock);
|
---|
[328] | 277 | echo $xpress_config->d3forum_option($do_message);
|
---|
| 278 | echo "</table>\n";
|
---|
| 279 |
|
---|
| 280 | echo '<p class="submit">'."\n";
|
---|
| 281 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 282 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 283 | echo "</p>\n";
|
---|
| 284 |
|
---|
| 285 | echo "</form>\n" ;
|
---|
| 286 | echo "</div>\n";
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | function other_option_page()
|
---|
| 290 | {
|
---|
| 291 | global $xoops_config,$xpress_config;
|
---|
| 292 |
|
---|
| 293 | $xoops_admin_url = $xoops_config->module_url . '/admin/index.php';
|
---|
| 294 |
|
---|
| 295 | $do_message ='';
|
---|
| 296 | if (!empty($_POST['submit_update'])) {
|
---|
| 297 | $xpress_config->ReadPostData($_POST);
|
---|
| 298 | $xpress_config->SettingValueWrite('update');
|
---|
| 299 | } else if (isset($_POST['submit_reset'])) {
|
---|
| 300 | $xpress_config->setDefault();
|
---|
| 301 | $xpress_config->SettingValueWrite('update');
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | echo '<div class="wrap">'."\n";
|
---|
| 305 | echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n";
|
---|
[332] | 306 | echo '<h2>' . __('XPressME Other Setting', 'xpressme') . "</h2><br>\n";
|
---|
[349] | 307 | // echo '<div align="right"><a href="' . $xoops_admin_url . '"><h3>'. __('to XOOPS Modules Admin Page', 'xpressme') . '</h3></a></div>';
|
---|
[328] | 308 | echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ;
|
---|
| 309 | echo '<table class="form-table">'."\n";
|
---|
| 310 | echo $xpress_config->yes_no_radio_option('is_save_post_revision',
|
---|
| 311 | __('The change tracking of the post is preserved','xpressme'),
|
---|
| 312 | __('YES','xpressme'),
|
---|
| 313 | __('NO','xpressme')
|
---|
| 314 | );
|
---|
| 315 |
|
---|
| 316 | echo $xpress_config->yes_no_radio_option('is_multi_user',
|
---|
| 317 | __('Select Multi user mode','xpressme'),
|
---|
| 318 | __('YES','xpressme'),
|
---|
| 319 | __('NO','xpressme')
|
---|
| 320 | );
|
---|
| 321 | echo $xpress_config->yes_no_radio_option('is_author_view_count',
|
---|
| 322 | __('Is the posts author views counted?','xpressme'),
|
---|
| 323 | __('YES','xpressme'),
|
---|
| 324 | __('NO','xpressme')
|
---|
| 325 | );
|
---|
| 326 | echo $xpress_config->header_meta_option();
|
---|
| 327 | echo $xpress_config->yes_no_radio_option('is_sql_debug',
|
---|
| 328 | __('Is SQL debugging window displayed?','xpressme'),
|
---|
| 329 | __('YES','xpressme'),
|
---|
| 330 | __('NO','xpressme')
|
---|
| 331 | );
|
---|
[448] | 332 | echo $xpress_config->yes_no_radio_option('is_block_error_display',
|
---|
| 333 | __('Select warning display of block file version check','xpressme'),
|
---|
| 334 | __('Do display','xpressme'),
|
---|
| 335 | __('Do not display','xpressme')
|
---|
| 336 | );
|
---|
[328] | 337 | echo "</table>\n";
|
---|
| 338 |
|
---|
| 339 | echo '<p class="submit">'."\n";
|
---|
| 340 | echo '<input type="submit" value= "' . __('Update Config', 'xpressme') . '" name="submit_update" />' ."\n";
|
---|
| 341 | echo '<input type="submit" value= "' . __('Preset Config', 'xpressme') . '" name="submit_reset" />' ."\n";
|
---|
| 342 | echo "</p>\n";
|
---|
| 343 |
|
---|
| 344 | echo "</form>\n" ;
|
---|
| 345 | echo "</div>\n";
|
---|
| 346 | }
|
---|
| 347 |
|
---|
[442] | 348 | include_once dirname( __FILE__ ).'/include/xpress_upgrade.php' ;
|
---|
[368] | 349 | add_action( 'admin_notices', 'xpress_update_check', 3 );
|
---|
[376] | 350 |
|
---|
| 351 | include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ;
|
---|
[453] | 352 | if(xpress_is_wp_version('>=','2.8')){
|
---|
| 353 | include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ;
|
---|
| 354 | }
|
---|
[18] | 355 | ?> |
---|