function spa_check_warnings() { global $spGlobals; # not perfect but we can use this call tyo perform any minor # cleanups that may be necessary... so # drop any existing temp members table... spdb_query('DROP TABLE IF EXISTS sftempmembers'); $mess = ''; # check if sp core, plugins or themes update available $update = false; $update_msg = ''; $up = get_site_transient('update_plugins'); if (!empty($up->response)) { foreach ($up->response as $plugin) { if ($plugin->slug == 'simple-press') { $msg = apply_filters('sph_core_update_notice', spa_text('There is a Simple:Press core update available.')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } break; } } } $up = get_site_transient('sp_update_plugins'); if (!empty($up)) { $msg = apply_filters('sph_plugins_update_notice', spa_text('There is one or more Simple:Press plugin updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } $up = get_site_transient('sp_update_themes'); if (!empty($up)) { $msg = apply_filters('sph_themes_update_notice', spa_text('There is one or more Simple:Press theme updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } if ($update) { if (is_main_site()) { $mess .= apply_filters('sph_updates_notice', spa_message($update_msg . '<a href="' . self_admin_url('update-core.php') . '">' . spa_text('Click here to view any updates.') . '</a>')); } else { $mess .= apply_filters('sph_updates_notice', spa_message(spa_text('There are some Simple:Press updates avaialable. You may want to notify the network site admin.'))); } } # output warning if no SPF admins are defined $a = $spGlobals['forum-admins']; if (empty($a)) { $mess .= spa_message(spa_text('Warning - There are no SPF admins defined! All WP admins now have SP backend access'), 'error'); } # Check if desktop, tablet and mobile themes are selected and available $cur = sp_get_option('sp_current_theme'); if (empty($cur)) { $mess .= spa_message(spa_text('No main theme has been selected and SP will be unable to display correctly. Please select a theme from the Themes panel'), 'error'); } else { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/' . $cur['style']); $nooverlay = !empty($cur['color']) && !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/overlays/' . $cur['color'] . '.php'); $nopoverlay = !empty($cur['color']) && !empty($cur['parent']) && !file_exists(SPTHEMEBASEDIR . $cur['parent'] . '/styles/overlays/' . $cur['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the theme CSS file and/or color Overlay file from the selected theme is missing'), 'error'); } } $mobile = sp_get_option('sp_mobile_theme'); if (!empty($mobile) && $mobile['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/' . $mobile['style']); $nooverlay = !empty($mobile['color']) && !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/overlays/' . $mobile['color'] . '.php'); $nopoverlay = !empty($mobile['color']) && !empty($mobile['parent']) && !file_exists(SPTHEMEBASEDIR . $mobile['parent'] . '/styles/overlays/' . $mobile['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the mobile theme CSS file and/or color Overlay file from the selected mobile theme is missing'), 'error'); } } $tablet = sp_get_option('sp_tablet_theme'); if (!empty($tablet) && $tablet['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/' . $tablet['style']); $nooverlay = !empty($tablet['color']) && !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/overlays/' . $tablet['color'] . '.php'); $nopoverlay = !empty($tablet['color']) && !empty($tablet['parent']) && !file_exists(SPTHEMEBASEDIR . $tablet['parent'] . '/styles/overlays/' . $tablet['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the tablet theme CSS file and/or color Overlay file from the selected tablet theme is missing'), 'error'); } } # check for missing default members user group $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for new members is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for missing default guest user group $value = sp_get_sfmeta('default usergroup', 'sfguests'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for guests is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for unreachable forums because of permissions $done = 0; $usergroups = spdb_table(SFUSERGROUPS); if ($usergroups) { $has_members = false; foreach ($usergroups as $usergroup) { $members = spdb_table(SFMEMBERSHIPS, "usergroup_id={$usergroup->usergroup_id}", 'row', '', '1'); if ($members || $usergroup->usergroup_id == $value[0]['meta_value']) { $has_members = true; break; } } if (!$has_members) { $mess .= spa_message(spa_text('Warning - There are no usergroups that have members! All forums may only be visible to SP admins'), 'error'); $done = 1; } } else { $mess .= spa_message(spa_text('Warning - There are no usergroups defined! All forums may only be visible to SP admins'), 'error'); $done = 1; } $roles = sp_get_all_roles(); if (!$roles) { $mess .= spa_message(spa_text('Warning - There are no permission sets defined! All forums may only be visible to SP admins'), 'error'); $done = 1; } # check if compatible with wp super cache if (function_exists('wp_cache_edit_rejected')) { global $cache_rejected_uri; $slug = '/' . sp_get_option('sfslug') . '/'; if (isset($cache_rejected_uri)) { $found = false; foreach ($cache_rejected_uri as $value) { if ($value == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('WP Super Cache is not properly configured to work with Simple:Press. Please visit your WP Super Cache settings page and in the accepted filenames & rejected URIs section for the pages not to be cached input field, add the following string'); $string .= ':<br /><br />' . $slug . '<br /><br />'; $string .= spa_text('Then, please clear your WP Super Cache cache to remove any cached Simple:Press pages'); $mess .= spa_message($string, 'error'); } } } if ($mess != '') { return $mess; } }
function spa_check_warnings() { global $spGlobals; # not perfect but we can use this call tyo perform any minor # cleanups that may be necessary... so # drop any existing temp members table... spdb_query('DROP TABLE IF EXISTS sftempmembers'); $mess = ''; # check if sp core, plugins or themes update available $update = false; $update_msg = ''; $up = get_site_transient('update_plugins'); if (!empty($up->response)) { foreach ($up->response as $plugin) { if ($plugin->slug == 'simple-press') { $msg = apply_filters('sph_core_update_notice', spa_text('There is a Simple:Press core update available.')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } break; } } } $up = get_site_transient('sp_update_plugins'); if (!empty($up)) { $msg = apply_filters('sph_plugins_update_notice', spa_text('There is one or more Simple:Press plugin updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } $up = get_site_transient('sp_update_themes'); if (!empty($up)) { $msg = apply_filters('sph_themes_update_notice', spa_text('There is one or more Simple:Press theme updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } if ($update) { if (is_main_site()) { $mess .= apply_filters('sph_updates_notice', spa_message($update_msg . '<a href="' . self_admin_url('update-core.php') . '">' . spa_text('Click here to view any updates.') . '</a>')); } else { $mess .= apply_filters('sph_updates_notice', spa_message(spa_text('There are some Simple:Press updates avaialable. You may want to notify the network site admin.'))); } } # output warning if no SPF admins are defined $a = $spGlobals['forum-admins']; if (empty($a)) { $mess .= spa_message(spa_text('Warning - There are no SPF admins defined! All WP admins now have SP backend access'), 'error'); } # Check if desktop, tablet and mobile themes are selected and available $cur = sp_get_option('sp_current_theme'); if (empty($cur)) { $mess .= spa_message(spa_text('No main theme has been selected and SP will be unable to display correctly. Please select a theme from the Themes panel'), 'error'); } else { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/' . $cur['style']); $nooverlay = !empty($cur['color']) && !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/overlays/' . $cur['color'] . '.php'); $nopoverlay = !empty($cur['color']) && !empty($cur['parent']) && !file_exists(SPTHEMEBASEDIR . $cur['parent'] . '/styles/overlays/' . $cur['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the theme CSS file and/or color Overlay file from the selected theme is missing'), 'error'); } } $mobile = sp_get_option('sp_mobile_theme'); if (!empty($mobile) && $mobile['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/' . $mobile['style']); $nooverlay = !empty($mobile['color']) && !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/overlays/' . $mobile['color'] . '.php'); $nopoverlay = !empty($mobile['color']) && !empty($mobile['parent']) && !file_exists(SPTHEMEBASEDIR . $mobile['parent'] . '/styles/overlays/' . $mobile['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the mobile theme CSS file and/or color Overlay file from the selected mobile theme is missing'), 'error'); } } $tablet = sp_get_option('sp_tablet_theme'); if (!empty($tablet) && $tablet['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/' . $tablet['style']); $nooverlay = !empty($tablet['color']) && !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/overlays/' . $tablet['color'] . '.php'); $nopoverlay = !empty($tablet['color']) && !empty($tablet['parent']) && !file_exists(SPTHEMEBASEDIR . $tablet['parent'] . '/styles/overlays/' . $tablet['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the tablet theme CSS file and/or color Overlay file from the selected tablet theme is missing'), 'error'); } } # check for missing default members user group $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for new members is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for missing default guest user group $value = sp_get_sfmeta('default usergroup', 'sfguests'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for guests is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for unreachable forums because of permissions $usergroups = spdb_table(SFUSERGROUPS); if ($usergroups) { $has_members = false; foreach ($usergroups as $usergroup) { $members = spdb_table(SFMEMBERSHIPS, "usergroup_id={$usergroup->usergroup_id}", 'row', '', '1'); if ($members || $usergroup->usergroup_id == $value[0]['meta_value']) { $has_members = true; break; } } if (!$has_members) { $mess .= spa_message(spa_text('Warning - There are no usergroups that have members! All forums may only be visible to SP admins'), 'error'); } } else { $mess .= spa_message(spa_text('Warning - There are no usergroups defined! All forums may only be visible to SP admins'), 'error'); } $roles = sp_get_all_roles(); if (!$roles) { $mess .= spa_message(spa_text('Warning - There are no permission sets defined! All forums may only be visible to SP admins'), 'error'); } # check if compatible with wp super cache if (function_exists('wp_cache_edit_rejected')) { global $cache_rejected_uri; $slug = '/' . sp_get_option('sfslug') . '/'; if (isset($cache_rejected_uri)) { $found = false; foreach ($cache_rejected_uri as $value) { if ($value == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('WP Super Cache is not properly configured to work with Simple:Press. Please visit your WP Super Cache settings page and in the accepted filenames & rejected URIs section for the pages not to be cached input field, add the following string'); $string .= ':</p><p><em>' . $slug . '</em></p><p>'; $string .= spa_text('Then, please clear your WP Super Cache cache to remove any cached Simple:Press pages'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/forum-displays-wrong-information/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } } } # check if compatible with w3 total cache (at leasst check for slug $f = WP_CONTENT_DIR . '/cache/config/master.php'; if (file_exists($f) && is_readable($f)) { $c = file_get_contents($f); $c = substr($c, 13); $config = @unserialize($c); if (key_exists('pgcache.reject.uri', $config) && !empty($config['pgcache.reject.uri'])) { $found = false; $slug = '/' . sp_get_option('sfslug') . '/'; foreach ($config['pgcache.reject.uri'] as $i) { if ($i == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('W3 Total Cache is not properly configured to work with Simple:Press. Please visit your W3 Total Cache settings page and in the accepted filenames & rejected URIs in ALL sections, add the following string'); $string .= ':</p><p><em>' . $slug . '</em></p><p>'; $string .= spa_text('Then, please clear your W3 Total Cache cache to remove any cached Simple:Press pages'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/forum-displays-wrong-information/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } } } # check for server-side UTC timezone $tz = get_option('timezone_string'); if (empty($tz)) { $tz = 'UTC ' . get_option('gmt_offset'); $string = spa_text('You have set your server to use a UTC timezone setting'); $string .= ':</p><p><em>' . $tz . '</em></p><p>'; $string .= spa_text('UTC can give unpredictable results on forum post time stamps. Please select the city setting nearest to you in the WordPress - Settings - General admin page'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/why-do-my-new-posts-show-as-posted-minus-seconds-ago/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } if ($mess != '') { return $mess; } }