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