Source: includes/class-config.php

  1. <?php
  2. namespace um;
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit;
  5. }
  6. if ( ! class_exists( 'um\Config' ) ) {
  7. /**
  8. * Class Config
  9. *
  10. * Class with global variables for UM
  11. *
  12. * @package um
  13. */
  14. class Config {
  15. /**
  16. * @var array
  17. */
  18. public $core_forms;
  19. /**
  20. * @var array
  21. */
  22. public $core_directories;
  23. /**
  24. * @var mixed|void
  25. */
  26. public $core_pages;
  27. /**
  28. * @since 2.8.3
  29. *
  30. * @var array
  31. */
  32. public $predefined_pages;
  33. /**
  34. * @var array
  35. */
  36. public $core_directory_meta = array();
  37. /**
  38. * @var array
  39. */
  40. public $core_global_meta_all;
  41. /**
  42. * @var mixed|void
  43. */
  44. public $core_form_meta_all;
  45. /**
  46. * @var array
  47. */
  48. public $core_form_meta = array();
  49. /**
  50. * @var
  51. */
  52. public $perms;
  53. /**
  54. * @var
  55. */
  56. public $nonadmin_perms;
  57. /**
  58. * @var mixed|void
  59. */
  60. public $email_notifications;
  61. /**
  62. * @var mixed|void
  63. */
  64. public $settings_defaults;
  65. /**
  66. * @var array
  67. */
  68. public $permalinks;
  69. /**
  70. * @var array|array[]
  71. */
  72. public $default_roles_metadata = array();
  73. public $permalink_base_options = array();
  74. public $display_name_options = array();
  75. /**
  76. * Config constructor.
  77. */
  78. public function __construct() {
  79. $this->core_forms = array(
  80. 'register',
  81. 'login',
  82. 'profile',
  83. );
  84. $this->core_directories = array(
  85. 'members',
  86. );
  87. /**
  88. * Filters Ultimate Member predefined pages.
  89. *
  90. * @param {array} $pages Predefined pages.
  91. *
  92. * @return {array} Predefined pages.
  93. *
  94. * @since 1.3.x
  95. * @hook um_core_pages
  96. *
  97. * @example <caption>Extend UM core pages.</caption>
  98. * function my_core_pages( $pages ) {
  99. * // your code here
  100. * $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ) );
  101. * return $pages;
  102. * }
  103. * add_filter( 'um_core_pages', 'my_core_pages' );
  104. */
  105. $this->core_pages = apply_filters(
  106. 'um_core_pages',
  107. array(
  108. 'user' => array( 'title' => __( 'User', 'ultimate-member' ) ),
  109. 'login' => array( 'title' => __( 'Login', 'ultimate-member' ) ),
  110. 'register' => array( 'title' => __( 'Register', 'ultimate-member' ) ),
  111. 'members' => array( 'title' => __( 'Members', 'ultimate-member' ) ),
  112. 'logout' => array( 'title' => __( 'Logout', 'ultimate-member' ) ),
  113. 'account' => array( 'title' => __( 'Account', 'ultimate-member' ) ),
  114. 'password-reset' => array( 'title' => __( 'Password Reset', 'ultimate-member' ) ),
  115. )
  116. );
  117. $this->core_directory_meta['members'] = array(
  118. '_um_core' => 'members',
  119. '_um_template' => 'members',
  120. '_um_mode' => 'directory',
  121. '_um_view_types' => array( 'grid' ),
  122. '_um_default_view' => 'grid',
  123. '_um_roles' => array(),
  124. '_um_has_profile_photo' => 0,
  125. '_um_has_cover_photo' => 0,
  126. '_um_show_these_users' => '',
  127. '_um_exclude_these_users' => '',
  128. '_um_sortby' => 'user_registered_desc',
  129. '_um_sortby_custom' => '',
  130. '_um_sortby_custom_label' => '',
  131. '_um_enable_sorting' => 0,
  132. '_um_sorting_fields' => array(),
  133. '_um_profile_photo' => '1',
  134. '_um_cover_photos' => '1',
  135. '_um_show_name' => '1',
  136. '_um_show_tagline' => 0,
  137. '_um_tagline_fields' => array(),
  138. '_um_show_userinfo' => 0,
  139. '_um_reveal_fields' => array(),
  140. '_um_show_social' => 0,
  141. '_um_userinfo_animate' => '1',
  142. '_um_search' => 0,
  143. '_um_roles_can_search' => array(),
  144. '_um_filters' => 0,
  145. '_um_roles_can_filter' => array(),
  146. '_um_search_fields' => array(),
  147. '_um_filters_expanded' => 0,
  148. '_um_filters_is_collapsible' => 1,
  149. '_um_search_filters' => array(),
  150. '_um_must_search' => 0,
  151. '_um_max_users' => '',
  152. '_um_profiles_per_page' => 12,
  153. '_um_profiles_per_page_mobile' => 6,
  154. '_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
  155. '_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
  156. '_um_directory_no_users' => __( 'We are sorry. We cannot find any users who match your search criteria.', 'ultimate-member' ),
  157. );
  158. $this->core_global_meta_all = array(
  159. '_um_primary_btn_color',
  160. '_um_primary_btn_hover',
  161. '_um_primary_btn_text',
  162. '_um_secondary_btn_color',
  163. '_um_secondary_btn_hover',
  164. '_um_secondary_btn_text',
  165. '_um_form_border',
  166. '_um_form_border_hover',
  167. '_um_form_bg_color',
  168. '_um_form_bg_color_focus',
  169. '_um_form_placeholder',
  170. '_um_form_icon_color',
  171. '_um_form_asterisk_color',
  172. '_um_form_field_label',
  173. '_um_form_text_color',
  174. '_um_active_color',
  175. '_um_help_tip_color',
  176. '_um_secondary_color',
  177. );
  178. $this->core_form_meta_all = array(
  179. /*Profile Form*/
  180. '_um_profile_show_name' => 1,
  181. '_um_profile_show_social_links' => 0,
  182. '_um_profile_show_bio' => 1,
  183. '_um_profile_bio_maxchars' => 180,
  184. '_um_profile_header_menu' => 'bc',
  185. '_um_profile_empty_text' => 1,
  186. '_um_profile_empty_text_emo' => 1,
  187. '_um_profile_role' => array(),
  188. '_um_profile_template' => 'profile',
  189. '_um_profile_max_width' => '1000px',
  190. '_um_profile_area_max_width' => '600px',
  191. '_um_profile_align' => 'center',
  192. '_um_profile_icons' => 'label',
  193. '_um_profile_disable_photo_upload' => 0,
  194. '_um_profile_photosize' => '190',
  195. '_um_profile_cover_enabled' => 1,
  196. '_um_profile_coversize' => 'original',
  197. '_um_profile_cover_ratio' => '2.7:1',
  198. '_um_profile_photocorner' => '1',
  199. '_um_profile_header_bg' => '',
  200. '_um_profile_primary_btn_word' => __( 'Update Profile', 'ultimate-member' ),
  201. '_um_profile_secondary_btn' => '1',
  202. '_um_profile_secondary_btn_word' => __( 'Cancel', 'ultimate-member' ),
  203. /*Registration Form*/
  204. '_um_register_role' => '0',
  205. '_um_register_template' => 'register',
  206. '_um_register_max_width' => '450px',
  207. '_um_register_align' => 'center',
  208. '_um_register_icons' => 'label',
  209. '_um_register_primary_btn_word' => __( 'Register', 'ultimate-member' ),
  210. '_um_register_secondary_btn' => 1,
  211. '_um_register_secondary_btn_word' => __( 'Login', 'ultimate-member' ),
  212. '_um_register_secondary_btn_url' => '',
  213. /*Login Form*/
  214. '_um_login_template' => 'login',
  215. '_um_login_max_width' => '450px',
  216. '_um_login_align' => 'center',
  217. '_um_login_icons' => 'label',
  218. '_um_login_primary_btn_word' => __( 'Login', 'ultimate-member' ),
  219. '_um_login_forgot_pass_link' => 1,
  220. '_um_login_show_rememberme' => 1,
  221. '_um_login_secondary_btn' => 1,
  222. '_um_login_secondary_btn_word' => __( 'Register', 'ultimate-member' ),
  223. '_um_login_secondary_btn_url' => '',
  224. /*Member Directory*/
  225. '_um_directory_template' => 'members',
  226. '_um_directory_header' => __( '{total_users} Members', 'ultimate-member' ),
  227. '_um_directory_header_single' => __( '{total_users} Member', 'ultimate-member' ),
  228. );
  229. /**
  230. * Filters the list of Ultimate Member forms meta.
  231. *
  232. * @param {array} $form_meta UM Forms meta.
  233. *
  234. * @return {array} Forms meta.
  235. *
  236. * @since 1.3.x
  237. * @hook um_core_form_meta_all
  238. *
  239. * @example <caption>Add custom admin notice after {custom_update_key} action.</caption>
  240. * function my_um_core_form_meta_all( $form_meta ) {
  241. * // your code here
  242. * $meta['my_meta_key'] = 'my_meta_value';
  243. * return $meta;
  244. * }
  245. * add_filter( 'um_core_form_meta_all', 'my_um_core_form_meta_all' );
  246. */
  247. $this->core_form_meta_all = apply_filters( 'um_core_form_meta_all', $this->core_form_meta_all );
  248. $this->core_form_meta['register'] = array(
  249. '_um_custom_fields' => array(
  250. 'user_login' => array(
  251. 'title' => __( 'Username', 'ultimate-member' ),
  252. 'metakey' => 'user_login',
  253. 'type' => 'text',
  254. 'label' => __( 'Username', 'ultimate-member' ),
  255. 'required' => 1,
  256. 'public' => 1,
  257. 'editable' => false,
  258. 'validate' => 'unique_username',
  259. 'min_chars' => 3,
  260. 'max_chars' => 24,
  261. 'position' => '1',
  262. 'in_row' => '_um_row_1',
  263. 'in_sub_row' => '0',
  264. 'in_column' => '1',
  265. 'in_group' => '',
  266. ),
  267. 'user_email' => array(
  268. 'title' => __( 'E-mail Address', 'ultimate-member' ),
  269. 'metakey' => 'user_email',
  270. 'type' => 'text',
  271. 'label' => __( 'E-mail Address', 'ultimate-member' ),
  272. 'required' => 0,
  273. 'public' => 1,
  274. 'editable' => true,
  275. 'validate' => 'unique_email',
  276. 'position' => '4',
  277. 'in_row' => '_um_row_1',
  278. 'in_sub_row' => '0',
  279. 'in_column' => '1',
  280. 'in_group' => '',
  281. ),
  282. 'user_password' => array(
  283. 'title' => __( 'Password', 'ultimate-member' ),
  284. 'metakey' => 'user_password',
  285. 'type' => 'password',
  286. 'label' => __( 'Password', 'ultimate-member' ),
  287. 'required' => 1,
  288. 'public' => 1,
  289. 'editable' => true,
  290. 'min_chars' => 8,
  291. 'max_chars' => 30,
  292. 'force_good_pass' => 1,
  293. 'force_confirm_pass' => 1,
  294. 'position' => '5',
  295. 'in_row' => '_um_row_1',
  296. 'in_sub_row' => '0',
  297. 'in_column' => '1',
  298. 'in_group' => '',
  299. ),
  300. 'first_name' => array(
  301. 'title' => __( 'First Name', 'ultimate-member' ),
  302. 'metakey' => 'first_name',
  303. 'type' => 'text',
  304. 'label' => __( 'First Name', 'ultimate-member' ),
  305. 'required' => 0,
  306. 'public' => 1,
  307. 'editable' => true,
  308. 'position' => '2',
  309. 'in_row' => '_um_row_1',
  310. 'in_sub_row' => '0',
  311. 'in_column' => '1',
  312. 'in_group' => '',
  313. ),
  314. 'last_name' => array(
  315. 'title' => __( 'Last Name', 'ultimate-member' ),
  316. 'metakey' => 'last_name',
  317. 'type' => 'text',
  318. 'label' => __( 'Last Name', 'ultimate-member' ),
  319. 'required' => 0,
  320. 'public' => 1,
  321. 'editable' => true,
  322. 'position' => '3',
  323. 'in_row' => '_um_row_1',
  324. 'in_sub_row' => '0',
  325. 'in_column' => '1',
  326. 'in_group' => '',
  327. ),
  328. '_um_row_1' => array(
  329. 'type' => 'row',
  330. 'id' => '_um_row_1',
  331. 'sub_rows' => '1',
  332. 'cols' => '1',
  333. ),
  334. ),
  335. '_um_mode' => 'register',
  336. '_um_core' => 'register',
  337. '_um_register_use_custom_settings' => 0,
  338. );
  339. $this->core_form_meta['login'] = array(
  340. '_um_custom_fields' => array(
  341. 'username' => array(
  342. 'title' => __( 'Username or E-mail', 'ultimate-member' ),
  343. 'metakey' => 'username',
  344. 'type' => 'text',
  345. 'label' => __( 'Username or E-mail', 'ultimate-member' ),
  346. 'required' => 1,
  347. 'public' => 1,
  348. 'editable' => false,
  349. 'validate' => 'unique_username_or_email',
  350. 'position' => '1',
  351. 'in_row' => '_um_row_1',
  352. 'in_sub_row' => '0',
  353. 'in_column' => '1',
  354. 'in_group' => '',
  355. ),
  356. 'user_password' => array(
  357. 'title' => __( 'Password', 'ultimate-member' ),
  358. 'metakey' => 'user_password',
  359. 'type' => 'password',
  360. 'label' => __( 'Password', 'ultimate-member' ),
  361. 'required' => 1,
  362. 'public' => 1,
  363. 'editable' => true,
  364. 'min_chars' => 8,
  365. 'max_chars' => 30,
  366. 'force_good_pass' => 1,
  367. 'force_confirm_pass' => 1,
  368. 'position' => '2',
  369. 'in_row' => '_um_row_1',
  370. 'in_sub_row' => '0',
  371. 'in_column' => '1',
  372. 'in_group' => '',
  373. ),
  374. '_um_row_1' => array(
  375. 'type' => 'row',
  376. 'id' => '_um_row_1',
  377. 'sub_rows' => '1',
  378. 'cols' => '1',
  379. ),
  380. ),
  381. '_um_mode' => 'login',
  382. '_um_core' => 'login',
  383. '_um_login_use_custom_settings' => 0,
  384. );
  385. $this->core_form_meta['profile'] = array(
  386. '_um_custom_fields' => array(
  387. '_um_row_1' => array(
  388. 'type' => 'row',
  389. 'id' => '_um_row_1',
  390. 'sub_rows' => '1',
  391. 'cols' => '1',
  392. ),
  393. ),
  394. '_um_mode' => 'profile',
  395. '_um_core' => 'profile',
  396. '_um_profile_use_custom_settings' => 0,
  397. );
  398. $this->email_notifications = array(
  399. 'welcome_email' => array(
  400. 'key' => 'welcome_email',
  401. 'title' => __( 'Account Welcome Email','ultimate-member' ),
  402. 'subject' => 'Welcome to {site_name}!',
  403. 'body' => 'Hi {display_name},<br /><br />' .
  404. 'Thank you for signing up with {site_name}! Your account is now active.<br /><br />' .
  405. '{action_title}:<br /><br />' .
  406. '{action_url} <br /><br />' .
  407. 'Your account email: {email} <br />' .
  408. 'Your account username: {username} <br /><br />' .
  409. 'If you have any problems, please contact us at {admin_email}<br /><br />' .
  410. 'Thanks,<br />' .
  411. '{site_name}',
  412. 'description' => __('Whether to send the user an email when his account is automatically approved','ultimate-member'),
  413. 'recipient' => 'user',
  414. 'default_active' => true
  415. ),
  416. 'checkmail_email' => array(
  417. 'key' => 'checkmail_email',
  418. 'title' => __( 'Account Activation Email','ultimate-member' ),
  419. 'subject' => 'Please activate your account',
  420. 'body' => 'Hi {display_name},<br /><br />' .
  421. 'Thank you for signing up with {site_name}! To activate your account, please click the link below to confirm your email address:<br /><br />' .
  422. '{account_activation_link} <br /><br />' .
  423. 'If you have any problems, please contact us at {admin_email}<br /><br />' .
  424. 'Thanks, <br />' .
  425. '{site_name}',
  426. 'description' => __('Whether to send the user an email when his account needs email activation','ultimate-member'),
  427. 'recipient' => 'user'
  428. ),
  429. 'pending_email' => array(
  430. 'key' => 'pending_email',
  431. 'title' => __( 'Your account is pending review','ultimate-member' ),
  432. 'subject' => '[{site_name}] New user account',
  433. 'body' => 'Hi {display_name}, <br /><br />' .
  434. 'Thank you for signing up with {site_name}! Your account is currently being reviewed by a member of our team.<br /><br />' .
  435. 'Please allow us some time to process your request.<br /><br />' .
  436. 'If you have any problems, please contact us at {admin_email}<br /><br />' .
  437. 'Thanks,<br />' .
  438. '{site_name}',
  439. 'description' => __('Whether to send the user an email when his account needs admin review','ultimate-member'),
  440. 'recipient' => 'user'
  441. ),
  442. 'approved_email' => array(
  443. 'key' => 'approved_email',
  444. 'title' => __( 'Account Approved Email','ultimate-member' ),
  445. 'subject' => 'Your account at {site_name} is now active',
  446. 'body' => 'Hi {display_name},<br /><br />' .
  447. 'Thank you for signing up with {site_name}! Your account has been approved and is now active.<br /><br />' .
  448. 'To login please visit the following url:<br /><br />' .
  449. '{login_url}<br /><br />' .
  450. 'Your account email: {email}<br />' .
  451. 'Your account username: {username}<br />' .
  452. 'Set your account password: {password_reset_link}<br /><br />' .
  453. 'If you have any problems, please contact us at {admin_email}<br /><br />' .
  454. 'Thanks,<br />' .
  455. '{site_name}',
  456. 'description' => __('Whether to send the user an email when his account is approved','ultimate-member'),
  457. 'recipient' => 'user'
  458. ),
  459. 'rejected_email' => array(
  460. 'key' => 'rejected_email',
  461. 'title' => __( 'Account Rejected Email','ultimate-member' ),
  462. 'subject' => 'Your account has been rejected',
  463. 'body' => 'Hi {display_name},<br /><br />' .
  464. 'Thank you for applying for membership to {site_name}! We have reviewed your information and unfortunately we are unable to accept you as a member at this moment.<br /><br />' .
  465. 'Please feel free to apply again at a future date.<br /><br />' .
  466. 'Thanks,<br />' .
  467. '{site_name}',
  468. 'description' => __('Whether to send the user an email when his account is rejected','ultimate-member'),
  469. 'recipient' => 'user'
  470. ),
  471. 'inactive_email' => array(
  472. 'key' => 'inactive_email',
  473. 'title' => __( 'Account Deactivated Email','ultimate-member' ),
  474. 'subject' => 'Your account has been deactivated',
  475. 'body' => 'Hi {display_name},<br /><br />' .
  476. 'This is an automated email to let you know your {site_name} account has been deactivated.<br /><br />' .
  477. 'If you would like your account to be reactivated please contact us at {admin_email}<br /><br />' .
  478. 'Thanks,<br />' .
  479. '{site_name}',
  480. 'description' => __('Whether to send the user an email when his account is deactivated','ultimate-member'),
  481. 'recipient' => 'user',
  482. 'default_active' => true
  483. ),
  484. 'deletion_email' => array(
  485. 'key' => 'deletion_email',
  486. 'title' => __( 'Account Deleted Email','ultimate-member' ),
  487. 'subject' => 'Your account has been deleted',
  488. 'body' => 'Hi {display_name},<br /><br />' .
  489. 'This is an automated email to let you know your {site_name} account has been deleted. All of your personal information has been permanently deleted and you will no longer be able to login to {site_name}.<br /><br />' .
  490. 'If your account has been deleted by accident please contact us at {admin_email} <br />' .
  491. 'Thanks,<br />' .
  492. '{site_name}',
  493. 'description' => __('Whether to send the user an email when his account is deleted','ultimate-member'),
  494. 'recipient' => 'user',
  495. 'default_active' => true
  496. ),
  497. 'resetpw_email' => array(
  498. 'key' => 'resetpw_email',
  499. 'title' => __( 'Password Reset Email','ultimate-member' ),
  500. 'subject' => 'Reset your password',
  501. 'body' => 'Hi {display_name},<br /><br />' .
  502. 'We received a request to reset the password for your account. If you made this request, click the link below to change your password:<br /><br />' .
  503. '{password_reset_link}<br /><br />' .
  504. 'If you didn\'t make this request, you can ignore this email <br /><br />' .
  505. 'Thanks,<br />' .
  506. '{site_name}',
  507. 'description' => __('Whether to send an email when users changed their password (Recommended, please keep on)','ultimate-member'),
  508. 'recipient' => 'user',
  509. 'default_active' => true
  510. ),
  511. 'changedpw_email' => array(
  512. 'key' => 'changedpw_email',
  513. 'title' => __( 'Password Changed Email','ultimate-member' ),
  514. 'subject' => 'Your {site_name} password has been changed',
  515. 'body' => 'Hi {display_name},<br /><br />' .
  516. 'You recently changed the password associated with your {site_name} account.<br /><br />' .
  517. 'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
  518. 'Thanks,<br />' .
  519. '{site_name}',
  520. 'description' => __('Whether to send the user an email when he requests to reset password (Recommended, please keep on)','ultimate-member'),
  521. 'recipient' => 'user',
  522. 'default_active' => true
  523. ),
  524. 'changedaccount_email' => array(
  525. 'key' => 'changedaccount_email',
  526. 'title' => __( 'Account Updated Email','ultimate-member' ),
  527. 'subject' => 'Your account at {site_name} was updated',
  528. 'body' => 'Hi {display_name},<br /><br />' .
  529. 'You recently updated your {site_name} account.<br /><br />' .
  530. 'If you did not make this change and believe your {site_name} account has been compromised, please contact us at the following email address: {admin_email}<br /><br />' .
  531. 'Thanks,<br />' .
  532. '{site_name}',
  533. 'description' => __('Whether to send the user an email when he updated their account','ultimate-member'),
  534. 'recipient' => 'user',
  535. 'default_active'=> true
  536. ),
  537. 'notification_new_user' => array(
  538. 'key' => 'notification_new_user',
  539. 'title' => __( 'New User Notification','ultimate-member' ),
  540. 'subject' => '[{site_name}] New user account',
  541. 'body' => '{display_name} has just created an account on {site_name}. To view their profile click here:<br /><br />' .
  542. '{user_profile_link}<br /><br />' .
  543. 'Here is the submitted registration form:<br /><br />' .
  544. '{submitted_registration}',
  545. 'description' => __('Whether to receive notification when a new user account is created','ultimate-member'),
  546. 'recipient' => 'admin',
  547. 'default_active' => true
  548. ),
  549. 'notification_review' => array(
  550. 'key' => 'notification_review',
  551. 'title' => __( 'Account Needs Review Notification','ultimate-member' ),
  552. 'subject' => '[{site_name}] New user awaiting review',
  553. 'body' => '{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.<br /><br />' .
  554. 'To review this member please click the following link:<br /><br />' .
  555. '{user_profile_link}<br /><br />' .
  556. 'Here is the submitted registration form:<br /><br />' .
  557. '{submitted_registration}',
  558. 'description' => __('Whether to receive notification when an account needs admin review','ultimate-member'),
  559. 'recipient' => 'admin'
  560. ),
  561. 'notification_deletion' => array(
  562. 'key' => 'notification_deletion',
  563. 'title' => __( 'Account Deletion Notification','ultimate-member' ),
  564. 'subject' => '[{site_name}] Account deleted',
  565. 'body' => '{display_name} has just deleted their {site_name} account.',
  566. 'description' => __('Whether to receive notification when an account is deleted','ultimate-member'),
  567. 'recipient' => 'admin'
  568. ),
  569. 'suspicious-activity' => array(
  570. 'key' => 'suspicious-activity',
  571. 'title' => __( 'Security: Suspicious Account Activity', 'ultimate-member' ),
  572. 'subject' => __( '[{site_name}] Suspicious Account Activity', 'ultimate-member' ),
  573. 'body' => 'This is to inform you that there are suspicious activities with the following accounts: {user_profile_link}',
  574. 'description' => __( 'Whether to receive notification when suspicious account activity is detected.', 'ultimate-member' ),
  575. 'recipient' => 'admin',
  576. 'default_active' => true,
  577. ),
  578. );
  579. /**
  580. * Filters the list of Ultimate Member email notifications.
  581. *
  582. * @param {array} $email_notifications Email notifications.
  583. *
  584. * @return {array} Email notifications.
  585. *
  586. * @since 2.0.0
  587. * @hook um_email_notifications
  588. *
  589. * @example <caption>Add custom admin notice after {custom_update_key} action.</caption>
  590. * function my_um_email_notifications( $notifications ) {
  591. * // your code here
  592. * $emails['my_email'] = array(
  593. * 'key' => 'my_email',
  594. * 'title' => __( 'my_email_title','ultimate-member' ),
  595. * 'subject' => 'my_email_subject',
  596. * 'body' => 'my_email_body',
  597. * 'description' => 'my_email_description',
  598. * 'recipient' => 'user', // set 'admin' for make administrator as recipient
  599. * 'default_active' => true // can be false for make disabled by default
  600. * );
  601. *
  602. * return $emails;
  603. * }
  604. * add_filter( 'um_email_notifications', 'my_um_email_notifications' );
  605. */
  606. $this->email_notifications = apply_filters( 'um_email_notifications', $this->email_notifications );
  607. // Settings defaults.
  608. $this->settings_defaults = array(
  609. 'restricted_access_post_metabox' => array(
  610. 'post' => 1,
  611. 'page' => 1,
  612. ),
  613. 'disable_restriction_pre_queries' => false,
  614. 'uninstall_on_delete' => false,
  615. 'permalink_base' => 'user_login',
  616. 'permalink_base_custom_meta' => '',
  617. 'display_name' => 'full_name',
  618. 'display_name_field' => '',
  619. 'author_redirect' => true,
  620. 'members_page' => true,
  621. 'use_gravatars' => false,
  622. 'use_um_gravatar_default_builtin_image' => 'default',
  623. 'use_um_gravatar_default_image' => false,
  624. 'toggle_password' => false,
  625. 'require_strongpass' => false,
  626. 'password_min_chars' => 8,
  627. 'password_max_chars' => 30,
  628. 'account_tab_password' => true,
  629. 'account_tab_privacy' => true,
  630. 'account_tab_notifications' => true,
  631. 'account_tab_delete' => true,
  632. 'delete_account_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account enter your password below.', 'ultimate-member' ),
  633. 'delete_account_no_pass_required_text' => __( 'Are you sure you want to delete your account? This will erase all of your account data from the site. To delete your account, click on the button below.', 'ultimate-member' ),
  634. 'account_name' => true,
  635. 'account_name_disable' => false,
  636. 'account_name_require' => true,
  637. 'account_email' => true,
  638. 'account_general_password' => false,
  639. 'account_hide_in_directory' => true,
  640. 'account_hide_in_directory_default' => 'No',
  641. 'photo_thumb_sizes' => array( 40, 80, 190 ),
  642. 'cover_thumb_sizes' => array( 300, 600 ),
  643. 'accessible' => 0,
  644. 'access_redirect' => '',
  645. 'access_exclude_uris' => array(),
  646. 'home_page_accessible' => true,
  647. 'category_page_accessible' => true,
  648. 'restricted_post_title_replace' => true,
  649. 'restricted_access_post_title' => __( 'Restricted content', 'ultimate-member' ),
  650. 'restricted_access_message' => '',
  651. 'restricted_blocks' => false,
  652. 'enable_blocks' => false,
  653. 'restricted_block_message' => '',
  654. 'enable_reset_password_limit' => true,
  655. 'reset_password_limit_number' => 3,
  656. 'change_password_request_limit' => false,
  657. 'only_approved_user_reset_password' => true,
  658. 'blocked_emails' => '',
  659. 'blocked_words' => 'admin' . "\r\n" . 'administrator' . "\r\n" . 'webmaster' . "\r\n" . 'support' . "\r\n" . 'staff',
  660. 'allowed_choice_callbacks' => '',
  661. 'allow_url_redirect_confirm' => true,
  662. 'default_avatar' => '',
  663. 'default_cover' => '',
  664. 'disable_profile_photo_upload' => false,
  665. 'profile_show_metaicon' => false,
  666. 'profile_menu' => true,
  667. 'profile_menu_default_tab' => 'main',
  668. 'profile_menu_icons' => true,
  669. 'form_asterisk' => false,
  670. 'profile_title' => '{display_name} | {site_name}',
  671. 'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
  672. 'admin_email' => get_bloginfo( 'admin_email' ),
  673. 'mail_from' => get_bloginfo( 'name' ),
  674. 'mail_from_addr' => get_bloginfo( 'admin_email' ),
  675. 'email_html' => true,
  676. 'image_orientation_by_exif' => false,
  677. 'image_compression' => 60,
  678. 'image_max_width' => 1000,
  679. 'cover_min_width' => 1000,
  680. 'profile_photo_max_size' => 999999999,
  681. 'cover_photo_max_size' => 999999999,
  682. 'custom_roles_increment' => 1,
  683. 'um_profile_object_cache_stop' => false,
  684. 'rest_api_version' => '2.0',
  685. 'member_directory_own_table' => false,
  686. 'profile_show_bio' => false,
  687. 'profile_show_html_bio' => false,
  688. 'profile_bio_maxchars' => 180,
  689. 'profile_noindex' => 0,
  690. 'activation_link_expiry_time' => '',
  691. 'lock_register_forms' => false,
  692. 'display_login_form_notice' => false,
  693. 'secure_ban_admins_accounts' => false,
  694. 'banned_capabilities' => array( 'manage_options', 'promote_users', 'level_10' ),
  695. 'secure_notify_admins_banned_accounts' => false,
  696. 'secure_notify_admins_banned_accounts__interval' => 'instant',
  697. 'secure_allowed_redirect_hosts' => '',
  698. 'delete_comments' => false,
  699. 'enable_action_scheduler' => false,
  700. );
  701. add_filter( 'um_get_tabs_from_config', '__return_true' );
  702. $tabs = UM()->profile()->tabs();
  703. foreach ( $tabs as $id => $tab ) {
  704. if ( ! empty( $tab['hidden'] ) ) {
  705. continue;
  706. }
  707. $this->settings_defaults[ 'profile_tab_' . $id ] = 1;
  708. if ( ! isset( $tab['default_privacy'] ) ) {
  709. $this->settings_defaults[ 'profile_tab_' . $id . '_privacy' ] = 0;
  710. $this->settings_defaults[ 'profile_tab_' . $id . '_roles' ] = '';
  711. }
  712. }
  713. foreach ( $this->email_notifications as $key => $notification ) {
  714. $this->settings_defaults[ $key . '_on' ] = ! empty( $notification['default_active'] );
  715. $this->settings_defaults[ $key . '_sub' ] = $notification['subject'];
  716. $this->settings_defaults[ $key ] = $notification['body'];
  717. }
  718. foreach ( $this->core_pages as $page_s => $page ) {
  719. $page_id = UM()->options()->get_predefined_page_option_key( $page_s );
  720. $this->settings_defaults[ $page_id ] = '';
  721. }
  722. foreach ( $this->core_form_meta_all as $key => $value ) {
  723. $this->settings_defaults[ str_replace( '_um_', '', $key ) ] = $value;
  724. }
  725. /**
  726. * UM hook
  727. *
  728. * @type filter
  729. * @title um_default_settings_values
  730. * @description Extend UM default settings
  731. * @input_vars
  732. * [{"var":"$settings","type":"array","desc":"UM default settings"}]
  733. * @change_log
  734. * ["Since: 2.0"]
  735. * @usage
  736. * <?php add_filter( 'um_default_settings_values', 'function_name', 10, 1 ); ?>
  737. * @example
  738. * <?php
  739. * add_filter( 'um_default_settings_values', 'my_default_settings_values', 10, 1 );
  740. * function my_default_settings_values( $settings ) {
  741. * // your code here
  742. * return $settings;
  743. * }
  744. * ?>
  745. */
  746. $this->settings_defaults = apply_filters( 'um_default_settings_values', $this->settings_defaults );
  747. $this->permalinks = $this->get_core_pages();
  748. $this->default_roles_metadata = array(
  749. 'subscriber' => array(
  750. '_um_can_access_wpadmin' => 0,
  751. '_um_can_not_see_adminbar' => 1,
  752. '_um_can_edit_everyone' => 0,
  753. '_um_can_delete_everyone' => 0,
  754. '_um_can_edit_profile' => 1,
  755. '_um_can_delete_profile' => 1,
  756. '_um_after_login' => 'redirect_profile',
  757. '_um_after_logout' => 'redirect_home',
  758. '_um_default_homepage' => 1,
  759. '_um_can_view_all' => 1,
  760. '_um_can_make_private_profile' => 0,
  761. '_um_can_access_private_profile' => 0,
  762. '_um_status' => 'approved',
  763. '_um_auto_approve_act' => 'redirect_profile',
  764. ),
  765. 'author' => array(
  766. '_um_can_access_wpadmin' => 0,
  767. '_um_can_not_see_adminbar' => 1,
  768. '_um_can_edit_everyone' => 0,
  769. '_um_can_delete_everyone' => 0,
  770. '_um_can_edit_profile' => 1,
  771. '_um_can_delete_profile' => 1,
  772. '_um_after_login' => 'redirect_profile',
  773. '_um_after_logout' => 'redirect_home',
  774. '_um_default_homepage' => 1,
  775. '_um_can_view_all' => 1,
  776. '_um_can_make_private_profile' => 0,
  777. '_um_can_access_private_profile' => 0,
  778. '_um_status' => 'approved',
  779. '_um_auto_approve_act' => 'redirect_profile',
  780. ),
  781. 'contributor' => array(
  782. '_um_can_access_wpadmin' => 0,
  783. '_um_can_not_see_adminbar' => 1,
  784. '_um_can_edit_everyone' => 0,
  785. '_um_can_delete_everyone' => 0,
  786. '_um_can_edit_profile' => 1,
  787. '_um_can_delete_profile' => 1,
  788. '_um_after_login' => 'redirect_profile',
  789. '_um_after_logout' => 'redirect_home',
  790. '_um_default_homepage' => 1,
  791. '_um_can_view_all' => 1,
  792. '_um_can_make_private_profile' => 0,
  793. '_um_can_access_private_profile' => 0,
  794. '_um_status' => 'approved',
  795. '_um_auto_approve_act' => 'redirect_profile',
  796. ),
  797. 'editor' => array(
  798. '_um_can_access_wpadmin' => 0,
  799. '_um_can_not_see_adminbar' => 1,
  800. '_um_can_edit_everyone' => 0,
  801. '_um_can_delete_everyone' => 0,
  802. '_um_can_edit_profile' => 1,
  803. '_um_can_delete_profile' => 1,
  804. '_um_after_login' => 'redirect_profile',
  805. '_um_after_logout' => 'redirect_home',
  806. '_um_default_homepage' => 1,
  807. '_um_can_view_all' => 1,
  808. '_um_can_make_private_profile' => 0,
  809. '_um_can_access_private_profile' => 0,
  810. '_um_status' => 'approved',
  811. '_um_auto_approve_act' => 'redirect_profile',
  812. ),
  813. 'administrator' => array(
  814. '_um_can_access_wpadmin' => 1,
  815. '_um_can_not_see_adminbar' => 0,
  816. '_um_can_edit_everyone' => 1,
  817. '_um_can_delete_everyone' => 1,
  818. '_um_can_edit_profile' => 1,
  819. '_um_can_delete_profile' => 1,
  820. '_um_default_homepage' => 1,
  821. '_um_after_login' => 'redirect_admin',
  822. '_um_after_logout' => 'redirect_home',
  823. '_um_can_view_all' => 1,
  824. '_um_can_make_private_profile' => 1,
  825. '_um_can_access_private_profile' => 1,
  826. '_um_status' => 'approved',
  827. '_um_auto_approve_act' => 'redirect_profile',
  828. ),
  829. );
  830. $this->permalink_base_options = array(
  831. 'user_login' => __( 'Username', 'ultimate-member' ),
  832. 'name' => __( 'First and Last Name with \'.\'', 'ultimate-member' ),
  833. 'name_dash' => __( 'First and Last Name with \'-\'', 'ultimate-member' ),
  834. 'name_plus' => __( 'First and Last Name with \'+\'', 'ultimate-member' ),
  835. 'user_id' => __( 'User ID', 'ultimate-member' ),
  836. 'hash' => __( 'Unique hash string', 'ultimate-member' ),
  837. 'custom_meta' => __( 'Custom usermeta', 'ultimate-member' ),
  838. );
  839. $this->permalink_base_options = apply_filters( 'um_config_permalink_base_options', $this->permalink_base_options );
  840. $this->display_name_options = array(
  841. 'default' => __( 'Default WP Display Name', 'ultimate-member' ),
  842. 'nickname' => __( 'Nickname', 'ultimate-member' ),
  843. 'username' => __( 'Username', 'ultimate-member' ),
  844. 'full_name' => __( 'First name & last name', 'ultimate-member' ),
  845. 'sur_name' => __( 'Last name & first name', 'ultimate-member' ),
  846. 'initial_name' => __( 'First name & first initial of last name', 'ultimate-member' ),
  847. 'initial_name_f' => __( 'First initial of first name & last name', 'ultimate-member' ),
  848. 'first_name' => __( 'First name only', 'ultimate-member' ),
  849. 'field' => __( 'Custom field(s)', 'ultimate-member' ),
  850. );
  851. }
  852. /**
  853. * Get UM Pages
  854. *
  855. * @return array
  856. */
  857. function get_core_pages() {
  858. $permalink = array();
  859. $core_pages = array_keys( $this->core_pages );
  860. if ( empty( $core_pages ) ) {
  861. return $permalink;
  862. }
  863. foreach ( $core_pages as $page_key ) {
  864. $page_option_key = UM()->options()->get_predefined_page_option_key( $page_key );
  865. $permalink[ $page_key ] = UM()->options()->get( $page_option_key );
  866. }
  867. return $permalink;
  868. }
  869. /**
  870. * @todo make config class not cycled
  871. */
  872. public function set_core_page() {
  873. $this->core_pages = array(
  874. 'user' => array(
  875. 'title' => __( 'User', 'ultimate-member' ),
  876. ),
  877. 'login' => array(
  878. 'title' => __( 'Login', 'ultimate-member' ),
  879. ),
  880. 'register' => array(
  881. 'title' => __( 'Register', 'ultimate-member' ),
  882. ),
  883. 'members' => array(
  884. 'title' => __( 'Members', 'ultimate-member' ),
  885. ),
  886. 'logout' => array(
  887. 'title' => __( 'Logout', 'ultimate-member' ),
  888. ),
  889. 'account' => array(
  890. 'title' => __( 'Account', 'ultimate-member' ),
  891. ),
  892. 'password-reset' => array(
  893. 'title' => __( 'Password Reset', 'ultimate-member' ),
  894. ),
  895. );
  896. $this->core_pages = apply_filters( 'um_core_pages', $this->core_pages );
  897. }
  898. /**
  899. * Get variable from config
  900. *
  901. * @param string $key
  902. *
  903. * @return mixed
  904. *
  905. * @since 2.8.3
  906. */
  907. public function get( $key ) {
  908. if ( empty( $this->$key ) ) {
  909. $this->{'init_' . $key}();
  910. }
  911. return apply_filters( 'um_config_get', $this->$key, $key );
  912. }
  913. /**
  914. * Init plugin core pages.
  915. *
  916. * @since 2.8.3
  917. */
  918. public function init_predefined_pages() {
  919. $core_forms = get_option( 'um_core_forms', array() );
  920. $core_directories = get_option( 'um_core_directories', array() );
  921. $setup_shortcodes = array_merge(
  922. array(
  923. 'profile' => '',
  924. 'login' => '',
  925. 'register' => '',
  926. 'members' => '',
  927. ),
  928. array_merge( $core_forms, $core_directories )
  929. );
  930. $this->predefined_pages = array(
  931. 'user' => array(
  932. 'title' => __( 'User', 'ultimate-member' ),
  933. 'content' => ! empty( $setup_shortcodes['profile'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['profile'] . '"]' : '',
  934. ),
  935. 'login' => array(
  936. 'title' => __( 'Login', 'ultimate-member' ),
  937. 'content' => ! empty( $setup_shortcodes['login'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['login'] . '"]' : '',
  938. ),
  939. 'register' => array(
  940. 'title' => __( 'Register', 'ultimate-member' ),
  941. 'content' => ! empty( $setup_shortcodes['register'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['register'] . '"]' : '',
  942. ),
  943. 'members' => array(
  944. 'title' => __( 'Members', 'ultimate-member' ),
  945. 'content' => ! empty( $setup_shortcodes['members'] ) ? '[ultimatemember form_id="' . $setup_shortcodes['members'] . '"]' : '',
  946. ),
  947. 'logout' => array(
  948. 'title' => __( 'Logout', 'ultimate-member' ),
  949. 'content' => '',
  950. ),
  951. 'account' => array(
  952. 'title' => __( 'Account', 'ultimate-member' ),
  953. 'content' => '[ultimatemember_account]',
  954. ),
  955. 'password-reset' => array(
  956. 'title' => __( 'Password Reset', 'ultimate-member' ),
  957. 'content' => '[ultimatemember_password]',
  958. ),
  959. );
  960. /**
  961. * Filters Ultimate Member predefined pages.
  962. *
  963. * @param {array} $pages Predefined pages.
  964. *
  965. * @return {array} Predefined pages.
  966. *
  967. * @since 2.8.3
  968. * @hook um_predefined_pages
  969. *
  970. * @example <caption>Extend UM core pages.</caption>
  971. * function my_predefined_pages( $pages ) {
  972. * // your code here
  973. * $pages['my_page_key'] = array( 'title' => __( 'My Page Title', 'my-translate-key' ), 'content' => 'my-page-predefined-content' );
  974. * return $pages;
  975. * }
  976. * add_filter( 'um_predefined_pages', 'my_predefined_pages' );
  977. */
  978. $this->predefined_pages = apply_filters( 'um_predefined_pages', $this->predefined_pages );
  979. // since 2.8.3 legacy hook
  980. // @todo remove in 3.0 version
  981. $this->predefined_pages = apply_filters( 'um_core_pages', $this->predefined_pages );
  982. $this->core_pages = $this->predefined_pages;
  983. }
  984. }
  985. }