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