/** * Checks, if some BuddyPress pages overlap with M2 membership pages. * * In some cases people used the same page-ID for both BuddyPress * registration and M2 registration. This will cause problems and must be * resolved to have M2 and BuddyPress work symbiotically. * * @since 1.0.1.1 */ protected function collission_check() { $buddy_pages = MS_Factory::get_option('bp-pages'); if (!is_array($buddy_pages)) { // Okay, no BuddyPress pages set up yet. return; } $duplicates = array(); foreach ($buddy_pages as $type => $page_id) { $collission = MS_Model_Pages::get_page_by('id', $page_id); if ($collission) { $title = $collission->post_title; if (!$title) { $title = $collission->post_name; } $duplicates[] = sprintf('%s - %s', $page_id, $title); } } if (count($duplicates)) { $msg = sprintf('%s<br><br>%s', sprintf(__('BuddyPress uses a page that is also used as a Membership page by Membership 2.<br>Please assign a different page for either %sMembership 2%s or %sBuddyPress%s to avoid conflicts.', 'membership2'), '<a href="' . MS_Controller_Plugin::get_admin_url('settings') . '">', '</a>', '<a href="' . admin_url('admin.php?page=bp-page-settings') . '">', '</a>'), implode('<br>', $duplicates)); lib3()->ui->admin_message($msg, 'error'); } }
/** * Filter returns the default contents of a Membership Page if the URL param * &ms-default=1 is set. * * Effectively this will display the default contents inside the Post-Editor * without changing the page itself. Only after the user saves the content * it will affect the Membership page * * @since 1.0.0 * @param string $content Default page content. * @return string Modified page content. */ public function show_default_content($content) { static $Message = false; global $post, $post_type; if (!isset($_GET['ms-default'])) { return $content; } if ('1' != $_GET['ms-default']) { return $content; } if ('page' != $post_type) { return $content; } $ms_page = MS_Model_Pages::get_page_by('id', $post->ID); if (empty($ms_page)) { return $content; } $type = MS_Model_Pages::get_page_type($ms_page); if (!$Message) { $Message = true; lib3()->ui->admin_message(__('<strong>Tipp</strong>:<br />' . 'The page content is reset to the default content but is <em>not saved yet</em>!<br />' . 'You can simply close this page to keep your current page contents.', 'membership2')); } return MS_Model_Pages::get_default_content($type); }