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