PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 3.1
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v3.1
4.16.19 4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Admin / SettingsPages / MemberDirectories.php
wp-user-avatar / src / Admin / SettingsPages Last commit date
DragDropBuilder 5 years ago EmailSettings 5 years ago ShortcodeBuilder 5 years ago AbstractSettingsPage.php 5 years ago AddNewForm.php 5 years ago AdminFooter.php 5 years ago ExtensionsSettingsPage.php 5 years ago FormList.php 5 years ago Forms.php 5 years ago GeneralSettings.php 5 years ago IDUserColumn.php 5 years ago MemberDirectories.php 5 years ago MembersDirectoryList.php 5 years ago ToolsSettingsPage.php 5 years ago index.php 5 years ago
MemberDirectories.php
238 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages;
4
5 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\DragDropBuilder;
6 use ProfilePress\Core\Admin\SettingsPages\ShortcodeBuilder\EditShortcodeUserProfile\EditShortcodeUserProfile;
7 use ProfilePress\Core\Classes\FormRepository as FR;
8 use ProfilePress\Custom_Settings_Page_Api;
9
10 // Exit if accessed directly
11 if ( ! defined('ABSPATH')) {
12 exit;
13 }
14
15 class MemberDirectories extends AbstractSettingsPage
16 {
17 /**
18 * @var FormList
19 */
20 protected $wplist_instance;
21 protected $EditShortcodeMemberDirectoriesInstance;
22 protected $DragDropClassInstance;
23
24 public function __construct()
25 {
26 add_action('admin_menu', array($this, 'register_settings_page'));
27
28 add_filter('set-screen-option', array($this, 'set_screen'), 10, 3);
29 add_filter('set_screen_option_forms_per_page', array($this, 'set_screen'), 10, 3);
30
31 $this->EditShortcodeMemberDirectoriesInstance = EditShortcodeUserProfile::get_instance();
32
33 $this->DragDropClassInstance = DragDropBuilder::get_instance();
34 }
35
36 public function admin_page_title()
37 {
38 $page_title = esc_html__('Member Directories', 'wp-user-avatar');
39
40 if (isset($_GET['page'], $_GET['view']) && $_GET['page'] == PPRESS_MEMBER_DIRECTORIES_SLUG) {
41 $page_title = esc_html__('Add Member Directory', 'wp-user-avatar');
42 }
43
44 if (isset($_GET['view'], $_GET['form-type']) && $_GET['form-type'] == FR::MEMBERS_DIRECTORY_TYPE) {
45 $page_title = esc_html__('Edit Member Directory', 'wp-user-avatar');
46 }
47
48 return $page_title;
49 }
50
51 public function register_settings_page()
52 {
53 $hook = add_submenu_page(
54 PPRESS_SETTINGS_SLUG,
55 $this->admin_page_title() . ' - ProfilePress',
56 esc_html__('Member Directories', 'wp-user-avatar'),
57 'manage_options',
58 PPRESS_MEMBER_DIRECTORIES_SLUG,
59 array($this, 'settings_admin_page_callback')
60 );
61
62 add_action("load-$hook", array($this, 'screen_option'));
63 }
64
65
66 /**
67 * Save screen option.
68 *
69 * @param string $status
70 * @param string $option
71 * @param string $value
72 *
73 * @return mixed
74 */
75 public function set_screen($status, $option, $value)
76 {
77 return $value;
78 }
79
80 /**
81 * Screen options
82 */
83 public function screen_option()
84 {
85 if (isset($_GET['page'], $_GET['view']) && strpos($_GET['view'], 'edit-shortcode') !== false) return;
86
87 $args = [
88 'label' => esc_html__('Member Directories', 'wp-user-avatar'),
89 'default' => 10,
90 'option' => 'forms_per_page',
91 ];
92
93 add_screen_option('per_page', $args);
94
95 $this->wplist_instance = MembersDirectoryList::get_instance();
96 }
97
98 public function live_form_preview_btn($echo = true)
99 {
100 if ( ! isset($_GET['view'])) return;
101
102 $preview_url = add_query_arg(
103 ['pp_preview_form' => absint($_GET['id']), 'type' => FR::MEMBERS_DIRECTORY_TYPE],
104 home_url()
105 );
106
107 $html = "<a target='_blank' class=\"add-new-h2\" href=\"$preview_url\">" . esc_html__('Live Preview', 'wp-user-avatar') . '</a>';
108
109 if ($echo === false) {
110 return $html;
111 }
112
113 echo $html;
114 }
115
116 public function no_form_exist_redirect($form_id, $form_type)
117 {
118 if ( ! FR::form_id_exist($form_id, $form_type)) {
119 wp_safe_redirect(add_query_arg('form-type', $form_type, PPRESS_FORMS_SETTINGS_PAGE));
120 exit;
121 }
122 }
123
124 /**
125 * Build the settings page structure. I.e tab, sidebar.
126 *
127 * @return mixed|void
128 */
129 public function settings_admin_page_callback()
130 {
131 remove_all_actions('media_buttons');
132 remove_all_filters('media_buttons_context');
133 remove_all_filters('mce_buttons', 10);
134 remove_all_filters('mce_external_plugins', 10);
135
136 add_action('media_buttons', 'media_buttons');
137
138 if ( ! empty($_GET['view']) && $_GET['view'] == 'add-new') {
139 echo '<script type="text/javascript">var pp_is_member_directory = true;</script>';
140 return AddNewForm::get_instance()->settings_admin_page();
141 }
142
143 if ( ! empty($_GET['view'])) {
144
145 $form_id = absint($_GET['id']);
146
147 $page_header = $this->admin_page_title();
148
149 $shortcode_builder_page_header = sprintf(
150 '<div class="wrap ppSCB"><h2>%s %s</h2><form method="post">%s',
151 $page_header,
152 $this->live_form_preview_btn(false),
153 ppress_nonce_field()
154 );
155
156 if ($_GET['view'] == 'edit-shortcode-members-directory') {
157 Forms::get_instance()->no_form_exist_redirect($form_id, FR::MEMBERS_DIRECTORY_TYPE);
158 echo $shortcode_builder_page_header;
159 $this->EditShortcodeMemberDirectoriesInstance->edit_screen();
160 echo '</form></div>';
161
162 return;
163 }
164
165 add_filter('wp_cspa_settings_page_sidebar', [$this->DragDropClassInstance, 'sidebar_section']);
166 add_action('wp_cspa_before_closing_header', [$this, 'live_form_preview_btn']);
167
168 add_action('wp_cspa_main_content_area', function ($content, $option_name) {
169 if ($option_name != 'pp_edit_form') return $content;
170
171 if ($_GET['view'] == 'drag-drop-builder') {
172 ob_start();
173 $this->DragDropClassInstance->admin_page();
174
175 return ob_get_clean();
176 }
177 }, 10, 2);
178
179 $instance = Custom_Settings_Page_Api::instance();
180 $instance->option_name('pp_edit_form');
181 $instance->add_wrap_classes('pp-dnd-form-builder-wrap');
182 $instance->page_header($this->admin_page_title());
183 $this->register_core_settings($instance);
184
185 return $instance->build();
186 }
187
188 add_action('wp_cspa_main_content_area', array($this, 'wp_list_table'), 10, 2);
189 add_action('wp_cspa_before_closing_header', [$this, 'add_new_form_button']);
190
191 $instance = Custom_Settings_Page_Api::instance();
192 $instance->option_name(PPRESS_FORMS_DB_OPTION_NAME);
193 $instance->page_header($this->admin_page_title());
194 $this->register_core_settings($instance, true);
195 echo '<div class="pp-form-listing pp-forms">';
196 $instance->build(true);
197 echo '</div>';
198 }
199
200 public function add_new_form_button()
201 {
202 $url = add_query_arg('view', 'add-new', PPRESS_MEMBER_DIRECTORIES_SETTINGS_PAGE);
203 echo "<a class=\"add-new-h2\" href=\"$url\">" . esc_html__('Add New', 'wp-user-avatar') . '</a>';
204 }
205
206 /**
207 * @param string $content
208 * @param string $option_name settings Custom_Settings_Page_Api option name.
209 *
210 * @return string
211 */
212 public function wp_list_table($content, $option_name)
213 {
214 if ($option_name != PPRESS_FORMS_DB_OPTION_NAME) return $content;
215
216 $this->wplist_instance->prepare_items(FR::MEMBERS_DIRECTORY_TYPE);
217
218 ob_start();
219
220 $this->wplist_instance->display();
221
222 return ob_get_clean();
223 }
224
225 /**
226 * @return self
227 */
228 public static function get_instance()
229 {
230 static $instance = null;
231
232 if (is_null($instance)) {
233 $instance = new self();
234 }
235
236 return $instance;
237 }
238 }