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