/** * Display the full settings form, used either by first membership * "completed" popup and also by the general settings tab. * * @since 1.0.0 * @return string HTML code */ public function html_full_form() { $fields = $this->prepare_fields(); ob_start(); ?> <div class="ms-setup-form"> <?php if (!MS_Plugin::is_network_wide()) { ?> <div class="ms-setup-nav"> <div class="ms-title"> <i class="ms-icon dashicons dashicons-menu"></i> <?php _e('Please select pages you want to appear in your Navigation', MS_TEXT_DOMAIN); ?> </div> <div class="ms-description"> <?php printf(__('You can always change those later by going to %1$s in your admin sidebar.', MS_TEXT_DOMAIN), sprintf('<a href="%1$s" target="_blank">%2$s</a>', admin_url('nav-menus.php'), __('Appearance') . ' » ' . __('Menus'))); ?> </div> <?php echo '' . $this->show_menu_controls(); ?> </div> <?php } else { ?> <div class="ms-setup-site"> <div class="ms-title"> <i class="ms-icon dashicons dashicons-admin-network"></i> <?php _e('Select the Site that hosts Membership 2 Pages', MS_TEXT_DOMAIN); ?> </div> <div class="ms-description"> <?php _e('When you change the site new Membership 2 Pages are created on the selected site. You can customize or replace these pages at any time.', MS_TEXT_DOMAIN); ?> </div> <?php $site_options = MS_Helper_Settings::get_blogs(); $site_fields = array(array('type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'id' => 'network_site', 'title' => __('Select the site that hosts the Membership 2 Pages', MS_TEXT_DOMAIN), 'value' => MS_Model_Pages::get_site_info('id'), 'field_options' => $site_options, 'class' => 'ms-site-options'), array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'action', 'value' => 'network_site'), array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => '_wpnonce', 'value' => wp_create_nonce('network_site')), array('type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save', MS_TEXT_DOMAIN)), array('type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'class' => 'ms-setup-pages-cancel', 'value' => __('Cancel', MS_TEXT_DOMAIN))); ?> <div class="ms-setup-pages-site"> <div class="ms-setup-pages-site-info"><?php printf(__('Membership pages are located on site %s', MS_TEXT_DOMAIN), '<strong>' . MS_Model_Pages::get_site_info('title') . '</strong>'); ?> <a href="#change-site" class="ms-setup-pages-change-site"><?php _e('Change site...', MS_TEXT_DOMAIN); ?> </a></div> <div class="ms-setup-pages-site-form cf" style="display:none;"> <?php foreach ($site_fields as $field) { MS_Helper_Html::html_element($field); } ?> </div> </div> </div> <?php } ?> <div class="ms-setup-pages"> <div class="ms-title"> <i class="ms-icon dashicons dashicons-admin-page"></i> <?php _e('Membership 2 Pages', MS_TEXT_DOMAIN); ?> </div> <div class="ms-description"> <?php _e('Set Up Membership 2 Pages that will be displayed on your website.', MS_TEXT_DOMAIN); ?> </div> <?php if (is_array($fields['pages'])) { $page_types = array_keys($fields['pages']); $page_types_menu = array('memberships', 'register', 'account'); $page_types_rest = array_diff($page_types, $page_types_menu); $groups = array('in-menu' => $page_types_menu, 'no-menu' => $page_types_rest); $pages_site_id = MS_Model_Pages::get_site_info('id'); MS_Factory::select_blog($pages_site_id); foreach ($groups as $group_key => $group_items) { printf('<div class="ms-pages-group %1$s">', esc_attr($group_key)); foreach ($group_items as $key) { $field = $fields['pages'][$key]; ?> <div class="ms-settings-page-wrapper"> <?php MS_Helper_Html::html_element($field); ?> <div class="ms-action"> <?php MS_Helper_Html::html_link(array('id' => 'url_page_' . $field['value'], 'url' => '', 'value' => __('View Page', MS_TEXT_DOMAIN), 'target' => '_blank', 'data_ms' => array('base' => get_home_url($pages_site_id, 'index.php?page_id=')))); ?> <span> | </span> <?php MS_Helper_Html::html_link(array('id' => 'edit_url_page_' . $field['value'], 'url' => '', 'value' => __('Edit Page', MS_TEXT_DOMAIN), 'target' => '_blank', 'data_ms' => array('base' => get_admin_url($pages_site_id, 'post.php?action=edit&post=')))); ?> </div> </div> <?php } echo '</div>'; } } else { echo $fields['pages']; } MS_Factory::revert_blog(); ?> </div> </div> <?php $html = ob_get_clean(); return apply_filters('ms_view_settings_page_setup_to_html', $html); }
/** * Manages settings actions. * * Verifies GET and POST requests to manage settings. * * @since 1.0.0 */ public function admin_settings_manager() { MS_Helper_Settings::print_admin_message(); $this->get_active_tab(); $msg = 0; $redirect = false; if ($this->is_admin_user()) { if ($this->verify_nonce() || $this->verify_nonce(null, 'GET')) { /** * After verifying permissions those filters can be used by Add-ons * to process their own settings form. * * @since 1.0.1.0 */ do_action('ms_admin_settings_manager-' . $this->active_tab); do_action('ms_admin_settings_manager', $this->active_tab); switch ($this->active_tab) { case self::TAB_GENERAL: lib3()->array->equip_request('action', 'network_site'); $action = $_REQUEST['action']; $redirect = esc_url_raw(remove_query_arg(array('msg' => $msg))); // See if we change settings for the network-wide mode. if (MS_Plugin::is_network_wide()) { $new_site_id = intval($_REQUEST['network_site']); if ('network_site' == $action && !empty($new_site_id)) { $old_site_id = MS_Model_Pages::get_setting('site_id'); if ($old_site_id != $new_site_id) { MS_Model_Pages::set_setting('site_id', $new_site_id); $msg = MS_Helper_Settings::SETTINGS_MSG_SITE_UPDATED; $redirect = esc_url_raw(add_query_arg(array('msg' => $msg))); } } } break; case self::TAB_IMPORT: $tool = MS_Factory::create('MS_Controller_Import'); // Output is passed to the view via self::_message() $tool->process(); break; case self::TAB_PAYMENT: case self::TAB_MESSAGES: break; default: break; } } } if ($redirect) { wp_safe_redirect($redirect); exit; } }
/** * When network-wide protection is enabled then allow the user to choose the * source-site of the content. * * Protection options can only be changed on a site-by-site base. So if the * user has 3 sites he can protect all pages on all sites but has to select * each site individually here. * * @since 1.0.0 */ protected function site_filter() { if (!MS_Plugin::is_network_wide()) { return false; } $sites = MS_Helper_Settings::get_blogs(); $site_options = array(); $current_blog_id = MS_Factory::current_blog_id(); $admin_script = 'admin.php?' . $_SERVER['QUERY_STRING']; foreach ($sites as $blog_id => $title) { $key = get_admin_url($blog_id, $admin_script); if ($current_blog_id == $blog_id) { $current_value = $key; } $site_options[$key] = $title; } $site_list = array('id' => 'select-site', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $current_value, 'field_options' => $site_options); ?> <div class="ms-tab-container"> <label class="ms-tab-link" for="select-site"> <?php _e('Select Site', 'membership2'); ?> </label> </div> <div> <?php lib3()->html->element($site_list); ?> </div> <?php }