PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 3.2.2
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v3.2.2
4.17.2 4.17.1 4.17.0 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 4 years ago EmailSettings 4 years ago AbstractSettingsPage.php 4 years ago AddNewForm.php 4 years ago AdminFooter.php 5 years ago ExtensionsSettingsPage.php 4 years ago FormList.php 5 years ago Forms.php 4 years ago GeneralSettings.php 4 years ago IDUserColumn.php 5 years ago MailOptin.php 4 years ago MemberDirectories.php 4 years ago MembersDirectoryList.php 5 years ago ToolsSettingsPage.php 4 years ago index.php 5 years ago
MemberDirectories.php
246 lines
1 <?php
2
3 namespace ProfilePress\Core\Admin\SettingsPages;
4
5 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\DragDropBuilder;
6 use ProfilePress\Core\Classes\FormRepository as FR;
7 use ProfilePress\Custom_Settings_Page_Api;
8
9 // Exit if accessed directly
10 if ( ! defined('ABSPATH')) {
11 exit;
12 }
13
14 class MemberDirectories extends AbstractSettingsPage
15 {
16 /**
17 * @var FormList
18 */
19 protected $wplist_instance;
20 protected $EditShortcodeMemberDirectoriesInstance;
21 protected $DragDropClassInstance;
22
23 public function __construct()
24 {
25 add_action('ppress_register_menu_page', array($this, 'register_settings_page'));
26 add_action('ppress_admin_settings_page_member-directories', [$this, 'settings_admin_page_callback']);
27 add_action('ppress_admin_settings_page_add-new', [$this, 'settings_admin_page_callback']);
28
29 add_filter('set-screen-option', array($this, 'set_screen'), 10, 3);
30 add_filter('set_screen_option_forms_per_page', array($this, 'set_screen'), 10, 3);
31
32 $this->DragDropClassInstance = DragDropBuilder::get_instance();
33 }
34
35 public function admin_page_title()
36 {
37 $page_title = esc_html__('Member Directories', 'wp-user-avatar');
38
39 if (isset($_GET['page'], $_GET['view']) && $_GET['page'] == PPRESS_MEMBER_DIRECTORIES_SLUG) {
40 $page_title = esc_html__('Add Member Directory', 'wp-user-avatar');
41 }
42
43 if (isset($_GET['view'], $_GET['form-type']) && $_GET['form-type'] == FR::MEMBERS_DIRECTORY_TYPE) {
44 $page_title = esc_html__('Edit Member Directory', 'wp-user-avatar');
45 }
46
47 return $page_title;
48 }
49
50 public function register_settings_page()
51 {
52 $hook = add_submenu_page(
53 PPRESS_SETTINGS_SLUG,
54 $this->admin_page_title() . ' - ProfilePress',
55 esc_html__('Member Directories', 'wp-user-avatar'),
56 'manage_options',
57 PPRESS_MEMBER_DIRECTORIES_SLUG,
58 array($this, 'admin_page_callback')
59 );
60
61 add_action("load-$hook", array($this, 'screen_option'));
62 }
63
64 public function default_header_menu()
65 {
66 return 'member-directories';
67 }
68
69 /**
70 * Save screen option.
71 *
72 * @param string $status
73 * @param string $option
74 * @param string $value
75 *
76 * @return mixed
77 */
78 public function set_screen($status, $option, $value)
79 {
80 return $value;
81 }
82
83 /**
84 * Screen options
85 */
86 public function screen_option()
87 {
88 if (isset($_GET['page'], $_GET['view']) && strpos($_GET['view'], 'edit-shortcode') !== false) return;
89
90 $args = [
91 'label' => esc_html__('Member Directories', 'wp-user-avatar'),
92 'default' => 10,
93 'option' => 'forms_per_page',
94 ];
95
96 add_screen_option('per_page', $args);
97
98 if (isset($_GET['id']) || ppress_var($_GET, 'view') == 'add-new') {
99 add_filter('screen_options_show_screen', '__return_false');
100 }
101
102 $this->wplist_instance = MembersDirectoryList::get_instance();
103 }
104
105 public function live_form_preview_btn($echo = true)
106 {
107 if ( ! isset($_GET['view'])) return;
108
109 $preview_url = esc_url(add_query_arg(
110 ['pp_preview_form' => absint($_GET['id']), 'type' => FR::MEMBERS_DIRECTORY_TYPE],
111 home_url()
112 ));
113
114 $html = "<a target='_blank' class=\"add-new-h2\" href=\"$preview_url\">" . esc_html__('Live Preview', 'wp-user-avatar') . '</a>';
115
116 if ($echo === false) {
117 return $html;
118 }
119
120 echo $html;
121 }
122
123 public function no_form_exist_redirect($form_id, $form_type)
124 {
125 if ( ! FR::form_id_exist($form_id, $form_type)) {
126 wp_safe_redirect(add_query_arg('form-type', $form_type, PPRESS_FORMS_SETTINGS_PAGE));
127 exit;
128 }
129 }
130
131 /**
132 * Build the settings page structure. I.e tab, sidebar.
133 *
134 * @return mixed|void
135 */
136 public function settings_admin_page_callback()
137 {
138 remove_all_actions('media_buttons');
139 remove_all_filters('media_buttons_context');
140 remove_all_filters('mce_buttons', 10);
141 remove_all_filters('mce_external_plugins', 10);
142
143 add_action('media_buttons', 'media_buttons');
144
145 if ( ! empty($_GET['view']) && $_GET['view'] == 'add-new') {
146 echo '<script type="text/javascript">var pp_is_member_directory = true;</script>';
147
148 return AddNewForm::get_instance()->settings_admin_page();
149 }
150
151 if ( ! empty($_GET['view'])) {
152
153 $form_id = absint($_GET['id']);
154
155 $page_header = $this->admin_page_title();
156
157 $shortcode_builder_page_header = sprintf(
158 '<div class="wrap ppSCB"><h2>%s %s</h2><form method="post">%s',
159 esc_html($page_header),
160 $this->live_form_preview_btn(false),
161 ppress_nonce_field()
162 );
163
164 if ($_GET['view'] == 'edit-shortcode-members-directory') {
165 Forms::get_instance()->no_form_exist_redirect($form_id, FR::MEMBERS_DIRECTORY_TYPE);
166 echo $shortcode_builder_page_header;
167 $this->EditShortcodeMemberDirectoriesInstance->edit_screen();
168 echo '</form></div>';
169
170 return;
171 }
172
173 add_filter('wp_cspa_settings_page_sidebar', [$this->DragDropClassInstance, 'sidebar_section']);
174 add_action('wp_cspa_before_closing_header', [$this, 'live_form_preview_btn']);
175
176 add_action('wp_cspa_main_content_area', function ($content, $option_name) {
177 if ($option_name != 'pp_edit_form') return $content;
178
179 if ($_GET['view'] == 'drag-drop-builder') {
180 ob_start();
181 $this->DragDropClassInstance->admin_page();
182
183 return ob_get_clean();
184 }
185 }, 10, 2);
186
187 $instance = Custom_Settings_Page_Api::instance();
188 $instance->option_name('pp_edit_form');
189 $instance->add_wrap_classes('pp-dnd-form-builder-wrap');
190 $instance->page_header($this->admin_page_title());
191 $this->register_core_settings($instance);
192
193 return $instance->build();
194 }
195
196 add_action('wp_cspa_main_content_area', array($this, 'wp_list_table'), 10, 2);
197 add_action('wp_cspa_before_closing_header', [$this, 'add_new_form_button']);
198
199 $instance = Custom_Settings_Page_Api::instance();
200 $instance->option_name(PPRESS_FORMS_DB_OPTION_NAME);
201 $instance->page_header($this->admin_page_title());
202 $this->register_core_settings($instance, true);
203 echo '<div class="pp-form-listing pp-forms">';
204 $instance->build(true);
205 echo '</div>';
206 }
207
208 public function add_new_form_button()
209 {
210 $url = esc_url(add_query_arg('view', 'add-new', PPRESS_MEMBER_DIRECTORIES_SETTINGS_PAGE));
211 echo "<a class=\"add-new-h2\" href=\"$url\">" . esc_html__('Add New', 'wp-user-avatar') . '</a>';
212 }
213
214 /**
215 * @param string $content
216 * @param string $option_name settings Custom_Settings_Page_Api option name.
217 *
218 * @return string
219 */
220 public function wp_list_table($content, $option_name)
221 {
222 if ($option_name != PPRESS_FORMS_DB_OPTION_NAME) return $content;
223
224 $this->wplist_instance->prepare_items(FR::MEMBERS_DIRECTORY_TYPE);
225
226 ob_start();
227
228 $this->wplist_instance->display();
229
230 return ob_get_clean();
231 }
232
233 /**
234 * @return self
235 */
236 public static function get_instance()
237 {
238 static $instance = null;
239
240 if (is_null($instance)) {
241 $instance = new self();
242 }
243
244 return $instance;
245 }
246 }