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