Нема описа

class-init.php 33KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. if ( ! class_exists( 'UM' ) ) {
  3. /**
  4. * Main UM Class
  5. *
  6. * @class UM
  7. * @version 2.0
  8. *
  9. * @method UM_bbPress_API bbPress_API()
  10. * @method UM_Followers_API Followers_API()
  11. * @method UM_Friends_API Friends_API()
  12. * @method UM_Instagram_API Instagram_API()
  13. * @method UM_Mailchimp Mailchimp()
  14. * @method UM_Messaging_API Messaging_API()
  15. * @method UM_myCRED myCRED()
  16. * @method UM_Notices Notices()
  17. * @method UM_Notifications_API Notifications_API()
  18. * @method UM_Online Online()
  19. * @method UM_Profile_Completeness_API Profile_Completeness_API()
  20. * @method UM_reCAPTCHA reCAPTCHA()
  21. * @method UM_Reviews Reviews()
  22. * @method UM_Activity_API Activity_API()
  23. * @method UM_Social_Login_API Social_Login_API()
  24. * @method UM_User_Tags User_Tags()
  25. * @method UM_Verified_Users_API Verified_Users_API()
  26. * @method UM_WooCommerce_API WooCommerce_API()
  27. * @method UM_Terms_Conditions Terms_Conditions()
  28. * @method UM_Private_Content Private_Content()
  29. * @method UM_User_Locations User_Locations()
  30. * @method UM_Photos_API Photos_API()
  31. * @method UM_Groups Groups()
  32. * @method UM_Frontend_Posting Frontend_Posting()
  33. * @method UM_Notes Notes()
  34. * @method UM_User_Bookmarks User_Bookmarks()
  35. * @method UM_Unsplash Unsplash()
  36. * @method UM_ForumWP ForumWP()
  37. * @method UM_Profile_Tabs Profile_Tabs()
  38. * @method UM_JobBoardWP JobBoardWP()
  39. * @method UM_Google_Authenticator Google_Authenticator()
  40. */
  41. final class UM extends UM_Functions {
  42. /**
  43. * @var UM the single instance of the class
  44. */
  45. protected static $instance = null;
  46. /**
  47. * @var array all plugin's classes
  48. */
  49. public $classes = array();
  50. /**
  51. * @var bool Old variable
  52. *
  53. * @todo deprecate this variable
  54. */
  55. public $is_filtering;
  56. /**
  57. * WP Native permalinks turned on?
  58. *
  59. * @var
  60. */
  61. public $is_permalinks;
  62. /**
  63. * Main UM Instance
  64. *
  65. * Ensures only one instance of UM is loaded or can be loaded.
  66. *
  67. * @since 1.0
  68. * @static
  69. * @see UM()
  70. * @return UM - Main instance
  71. */
  72. static public function instance() {
  73. if ( is_null( self::$instance ) ) {
  74. self::$instance = new self();
  75. self::$instance->_um_construct();
  76. }
  77. return self::$instance;
  78. }
  79. /**
  80. * Create plugin classes - not sure if it needs!!!!!!!!!!!!!!!
  81. *
  82. * @since 1.0
  83. * @see UM()
  84. *
  85. * @param $name
  86. * @param array $params
  87. * @return mixed
  88. */
  89. public function __call( $name, array $params ) {
  90. if ( empty( $this->classes[ $name ] ) ) {
  91. /**
  92. * UM hook
  93. *
  94. * @type filter
  95. * @title um_call_object_{$class_name}
  96. * @description Extend call classes of Extensions for use UM()->class_name()->method|function
  97. * @input_vars
  98. * [{"var":"$class","type":"object","desc":"Class Instance"}]
  99. * @change_log
  100. * ["Since: 2.0"]
  101. * @usage add_filter( 'um_call_object_{$class_name}', 'function_name', 10, 1 );
  102. * @example
  103. * <?php
  104. * add_filter( 'um_call_object_{$class_name}', 'my_extension_class', 10, 1 );
  105. * function my_extension_class( $class ) {
  106. * // your code here
  107. * return $class;
  108. * }
  109. * ?>
  110. */
  111. $this->classes[ $name ] = apply_filters( 'um_call_object_' . $name, false );
  112. }
  113. return $this->classes[ $name ];
  114. }
  115. /**
  116. * Function for add classes to $this->classes
  117. * for run using UM()
  118. *
  119. * @since 2.0
  120. *
  121. * @param string $class_name
  122. * @param bool $instance
  123. */
  124. public function set_class( $class_name, $instance = false ) {
  125. if ( empty( $this->classes[ $class_name ] ) ) {
  126. $class = 'UM_' . $class_name;
  127. $this->classes[ $class_name ] = $instance ? $class::instance() : new $class;
  128. }
  129. }
  130. /**
  131. * Cloning is forbidden.
  132. * @since 1.0
  133. */
  134. public function __clone() {
  135. _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'ultimate-member' ), '1.0' );
  136. }
  137. /**
  138. * Unserializing instances of this class is forbidden.
  139. * @since 1.0
  140. */
  141. public function __wakeup() {
  142. _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'ultimate-member' ), '1.0' );
  143. }
  144. /**
  145. * UM constructor.
  146. *
  147. * @since 1.0
  148. */
  149. function __construct() {
  150. parent::__construct();
  151. }
  152. /**
  153. * UM pseudo-constructor.
  154. *
  155. * @since 2.0.18
  156. */
  157. function _um_construct() {
  158. //register autoloader for include UM classes
  159. spl_autoload_register( array( $this, 'um__autoloader' ) );
  160. if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
  161. if ( get_option( 'permalink_structure' ) ) {
  162. $this->is_permalinks = true;
  163. }
  164. $this->is_filtering = 0;
  165. $this->honeypot = 'um_request';
  166. // textdomain loading
  167. $this->localize();
  168. // include UM classes
  169. $this->includes();
  170. // include hook files
  171. add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
  172. //run hook for extensions init
  173. add_action( 'plugins_loaded', array( &$this, 'extensions_init' ), -19 );
  174. add_action( 'init', array( &$this, 'old_update_patch' ), 0 );
  175. //run activation
  176. register_activation_hook( um_plugin, array( &$this, 'activation' ) );
  177. if ( is_multisite() && ! defined( 'DOING_AJAX' ) ) {
  178. add_action( 'wp_loaded', array( $this, 'maybe_network_activation' ) );
  179. }
  180. // init widgets
  181. add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
  182. //include short non class functions
  183. require_once 'um-short-functions.php';
  184. require_once 'um-deprecated-functions.php';
  185. }
  186. }
  187. /**
  188. * Loading UM textdomain
  189. *
  190. * 'ultimate-member' by default
  191. */
  192. function localize() {
  193. $language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
  194. /**
  195. * UM hook
  196. *
  197. * @type filter
  198. * @title um_language_locale
  199. * @description Change UM language locale
  200. * @input_vars
  201. * [{"var":"$locale","type":"string","desc":"UM language locale"}]
  202. * @change_log
  203. * ["Since: 2.0"]
  204. * @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
  205. * @example
  206. * <?php
  207. * add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
  208. * function my_language_locale( $locale ) {
  209. * // your code here
  210. * return $locale;
  211. * }
  212. * ?>
  213. */
  214. $language_locale = apply_filters( 'um_language_locale', $language_locale );
  215. /**
  216. * UM hook
  217. *
  218. * @type filter
  219. * @title um_language_textdomain
  220. * @description Change UM textdomain
  221. * @input_vars
  222. * [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
  223. * @change_log
  224. * ["Since: 2.0"]
  225. * @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
  226. * @example
  227. * <?php
  228. * add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
  229. * function my_textdomain( $domain ) {
  230. * // your code here
  231. * return $domain;
  232. * }
  233. * ?>
  234. */
  235. $language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
  236. $language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
  237. /**
  238. * UM hook
  239. *
  240. * @type filter
  241. * @title um_language_file
  242. * @description Change UM language file path
  243. * @input_vars
  244. * [{"var":"$language_file","type":"string","desc":"UM language file path"}]
  245. * @change_log
  246. * ["Since: 2.0"]
  247. * @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
  248. * @example
  249. * <?php
  250. * add_filter( 'um_language_file', 'my_language_file', 10, 1 );
  251. * function my_language_file( $language_file ) {
  252. * // your code here
  253. * return $language_file;
  254. * }
  255. * ?>
  256. */
  257. $language_file = apply_filters( 'um_language_file', $language_file );
  258. load_textdomain( $language_domain, $language_file );
  259. }
  260. /**
  261. * 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
  262. */
  263. function old_update_patch() {
  264. global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified;
  265. if ( is_object( $um_woocommerce ) ) {
  266. remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
  267. $um_woocommerce->plugin_inactive = true;
  268. }
  269. if ( is_object( $um_bbpress ) ) {
  270. remove_action( 'init', array( $um_bbpress, 'plugin_check' ), 4 );
  271. $um_bbpress->plugin_inactive = true;
  272. }
  273. if ( is_object( $um_followers ) ) {
  274. remove_action( 'init', array( $um_followers, 'plugin_check' ), 1 );
  275. $um_followers->plugin_inactive = true;
  276. }
  277. if ( is_object( $um_friends ) ) {
  278. remove_action( 'init', array( $um_friends, 'plugin_check' ), 1 );
  279. $um_friends->plugin_inactive = true;
  280. }
  281. if ( is_object( $um_mailchimp ) ) {
  282. remove_action( 'init', array( $um_mailchimp, 'plugin_check' ), 1 );
  283. $um_mailchimp->plugin_inactive = true;
  284. }
  285. if ( is_object( $um_messaging ) ) {
  286. remove_action( 'init', array( $um_messaging, 'plugin_check' ), 1 );
  287. $um_messaging->plugin_inactive = true;
  288. }
  289. if ( is_object( $um_mycred ) ) {
  290. remove_action( 'init', array( $um_mycred, 'plugin_check' ), 1 );
  291. $um_mycred->plugin_inactive = true;
  292. }
  293. if ( is_object( $um_notices ) ) {
  294. remove_action( 'init', array( $um_notices, 'plugin_check' ), 1 );
  295. $um_notices->plugin_inactive = true;
  296. }
  297. if ( is_object( $um_notifications ) ) {
  298. remove_action( 'init', array( $um_notifications, 'plugin_check' ), 1 );
  299. $um_notifications->plugin_inactive = true;
  300. }
  301. if ( is_object( $um_online ) ) {
  302. remove_action( 'init', array( $um_online, 'plugin_check' ), 1 );
  303. $um_online->plugin_inactive = true;
  304. }
  305. if ( is_object( $um_private_content ) ) {
  306. remove_action( 'init', array( $um_private_content, 'plugin_check' ), 1 );
  307. $um_private_content->plugin_inactive = true;
  308. }
  309. if ( is_object( $um_profile_completeness ) ) {
  310. remove_action( 'init', array( $um_profile_completeness, 'plugin_check' ), 1 );
  311. $um_profile_completeness->plugin_inactive = true;
  312. }
  313. if ( is_object( $um_recaptcha ) ) {
  314. remove_action( 'init', array( $um_recaptcha, 'plugin_check' ), 1 );
  315. $um_recaptcha->plugin_inactive = true;
  316. }
  317. if ( is_object( $um_reviews ) ) {
  318. remove_action( 'init', array( $um_reviews, 'plugin_check' ), 1 );
  319. $um_reviews->plugin_inactive = true;
  320. }
  321. if ( is_object( $um_activity ) ) {
  322. remove_action( 'init', array( $um_activity, 'plugin_check' ), 1 );
  323. $um_activity->plugin_inactive = true;
  324. }
  325. if ( is_object( $um_social_login ) ) {
  326. remove_action( 'init', array( $um_social_login, 'plugin_check' ), 1 );
  327. $um_social_login->plugin_inactive = true;
  328. }
  329. if ( is_object( $um_user_tags ) ) {
  330. remove_action( 'init', array( $um_user_tags, 'plugin_check' ), 1 );
  331. $um_user_tags->plugin_inactive = true;
  332. }
  333. if ( is_object( $um_verified ) ) {
  334. remove_action( 'init', array( $um_verified, 'plugin_check' ), 1 );
  335. $um_verified->plugin_inactive = true;
  336. }
  337. }
  338. /**
  339. * Autoload UM classes handler
  340. *
  341. * @since 2.0
  342. *
  343. * @param $class
  344. */
  345. function um__autoloader( $class ) {
  346. if ( strpos( $class, 'um' ) === 0 ) {
  347. $array = explode( '\\', strtolower( $class ) );
  348. $array[ count( $array ) - 1 ] = 'class-'. end( $array );
  349. if ( strpos( $class, 'um_ext' ) === 0 ) {
  350. $full_path = str_replace( 'ultimate-member', '', untrailingslashit( um_path ) ) . str_replace( '_', '-', $array[1] ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR;
  351. unset( $array[0], $array[1] );
  352. $path = implode( DIRECTORY_SEPARATOR, $array );
  353. $path = str_replace( '_', '-', $path );
  354. $full_path .= $path . '.php';
  355. } else if ( strpos( $class, 'um\\' ) === 0 ) {
  356. $class = implode( '\\', $array );
  357. $slash = DIRECTORY_SEPARATOR;
  358. $path = str_replace(
  359. array( 'um\\', '_', '\\' ),
  360. array( $slash, '-', $slash ),
  361. $class );
  362. $full_path = um_path . 'includes' . $path . '.php';
  363. }
  364. if( isset( $full_path ) && file_exists( $full_path ) ) {
  365. include_once $full_path;
  366. }
  367. }
  368. }
  369. /**
  370. * Plugin Activation
  371. *
  372. * @since 2.0
  373. */
  374. function activation() {
  375. $this->single_site_activation();
  376. if ( is_multisite() ) {
  377. update_network_option( get_current_network_id(), 'um_maybe_network_wide_activation', 1 );
  378. }
  379. }
  380. /**
  381. * Maybe need multisite activation process
  382. *
  383. * @since 2.1.7
  384. */
  385. function maybe_network_activation() {
  386. $maybe_activation = get_network_option( get_current_network_id(), 'um_maybe_network_wide_activation' );
  387. if ( $maybe_activation ) {
  388. delete_network_option( get_current_network_id(), 'um_maybe_network_wide_activation' );
  389. if ( is_plugin_active_for_network( um_plugin ) ) {
  390. // get all blogs
  391. $blogs = get_sites();
  392. if ( ! empty( $blogs ) ) {
  393. foreach( $blogs as $blog ) {
  394. switch_to_blog( $blog->blog_id );
  395. //make activation script for each sites blog
  396. $this->single_site_activation();
  397. restore_current_blog();
  398. }
  399. }
  400. }
  401. }
  402. }
  403. /**
  404. * Single site plugin activation handler
  405. */
  406. function single_site_activation() {
  407. //first install
  408. $version = get_option( 'um_version' );
  409. if ( ! $version ) {
  410. update_option( 'um_last_version_upgrade', ultimatemember_version );
  411. add_option( 'um_first_activation_date', time() );
  412. //show avatars on first install
  413. if ( ! get_option( 'show_avatars' ) ) {
  414. update_option( 'show_avatars', 1 );
  415. }
  416. } else {
  417. UM()->options()->update( 'rest_api_version', '1.0' );
  418. }
  419. if ( $version != ultimatemember_version ) {
  420. update_option( 'um_version', ultimatemember_version );
  421. }
  422. //run setup
  423. $this->common()->create_post_types();
  424. $this->setup()->run_setup();
  425. }
  426. /**
  427. *
  428. */
  429. function extensions_init() {
  430. do_action( 'um_core_loaded' );
  431. }
  432. /**
  433. * Include required core files used in admin and on the frontend.
  434. *
  435. * @since 2.0
  436. *
  437. * @return void
  438. */
  439. public function includes() {
  440. $this->common();
  441. $this->access();
  442. if ( $this->is_request( 'ajax' ) ) {
  443. $this->admin();
  444. $this->ajax_init();
  445. $this->admin_ajax_hooks();
  446. $this->metabox();
  447. $this->admin_upgrade()->init_packages_ajax_handlers();
  448. $this->admin_gdpr();
  449. $this->columns();
  450. $this->admin()->notices();
  451. $this->admin_navmenu();
  452. $this->plugin_updater();
  453. $this->theme_updater();
  454. } elseif ( $this->is_request( 'admin' ) ) {
  455. $this->admin();
  456. $this->admin_menu();
  457. $this->admin_upgrade();
  458. $this->admin_settings();
  459. $this->columns();
  460. $this->admin_enqueue();
  461. $this->metabox();
  462. $this->admin()->notices();
  463. $this->users();
  464. $this->dragdrop();
  465. $this->admin_gdpr();
  466. $this->admin_navmenu();
  467. $this->plugin_updater();
  468. $this->theme_updater();
  469. } elseif ( $this->is_request( 'frontend' ) ) {
  470. $this->enqueue();
  471. $this->account();
  472. $this->password();
  473. $this->login();
  474. $this->register();
  475. $this->user_posts();
  476. $this->logout();
  477. }
  478. //common includes
  479. $this->rewrite();
  480. $this->mail();
  481. $this->rest_api();
  482. $this->shortcodes();
  483. $this->roles();
  484. $this->user();
  485. $this->profile();
  486. $this->builtin();
  487. $this->form();
  488. $this->permalinks();
  489. $this->modal();
  490. $this->cron();
  491. $this->mobile();
  492. $this->external_integrations();
  493. $this->gdpr();
  494. $this->member_directory();
  495. //if multisite networks active
  496. if ( is_multisite() ) {
  497. $this->multisite();
  498. }
  499. }
  500. /**
  501. * @since 2.1.0
  502. *
  503. * @return um\core\Member_Directory()
  504. */
  505. function member_directory() {
  506. if ( empty( $this->classes['member_directory'] ) ) {
  507. $search_in_table = $this->options()->get( 'member_directory_own_table' );
  508. if ( ! empty( $search_in_table ) ) {
  509. $this->classes['member_directory'] = new um\core\Member_Directory_Meta();
  510. } else {
  511. $this->classes['member_directory'] = new um\core\Member_Directory();
  512. }
  513. }
  514. return $this->classes['member_directory'];
  515. }
  516. /**
  517. * Get extension API
  518. *
  519. * @since 2.0.34
  520. *
  521. * @param $slug
  522. *
  523. * @return um_ext\um_bbpress\Init
  524. */
  525. function extension( $slug ) {
  526. if ( empty( $this->classes[ $slug ] ) ) {
  527. $class = "um_ext\um_{$slug}\Init";
  528. /**
  529. * @var $class um_ext\um_bbpress\Init
  530. */
  531. $this->classes[ $slug ] = $class::instance();
  532. }
  533. return $this->classes[ $slug ];
  534. }
  535. /**
  536. * @param $class
  537. *
  538. * @return mixed
  539. */
  540. function call_class( $class ) {
  541. $key = strtolower( $class );
  542. if ( empty( $this->classes[ $key ] ) ) {
  543. $this->classes[ $key ] = new $class;
  544. }
  545. return $this->classes[ $key ];
  546. }
  547. /**
  548. * @since 2.0
  549. *
  550. * @return um\core\Common()
  551. */
  552. function common() {
  553. if ( empty( $this->classes['common'] ) ) {
  554. $this->classes['common'] = new um\core\Common();
  555. }
  556. return $this->classes['common'];
  557. }
  558. /**
  559. * @since 2.0
  560. *
  561. * @return um\core\External_Integrations()
  562. */
  563. function external_integrations() {
  564. if ( empty( $this->classes['external_integrations'] ) ) {
  565. $this->classes['external_integrations'] = new um\core\External_Integrations();
  566. }
  567. return $this->classes['external_integrations'];
  568. }
  569. /**
  570. * @since 2.0
  571. *
  572. * @return um\core\Options()
  573. */
  574. function options() {
  575. if ( empty( $this->classes['options'] ) ) {
  576. $this->classes['options'] = new um\core\Options();
  577. }
  578. return $this->classes['options'];
  579. }
  580. /**
  581. * @since 2.0
  582. *
  583. * @return um\core\Plugin_Updater()
  584. */
  585. function plugin_updater() {
  586. if ( empty( $this->classes['plugin_updater'] ) ) {
  587. $this->classes['plugin_updater'] = new um\core\Plugin_Updater();
  588. }
  589. return $this->classes['plugin_updater'];
  590. }
  591. /**
  592. * @since 2.0.45
  593. * @return um\admin\core\Admin_Theme_Updater()
  594. */
  595. function theme_updater() {
  596. if ( empty( $this->classes['theme_updater'] ) ) {
  597. $this->classes['theme_updater'] = new um\admin\core\Admin_Theme_Updater();
  598. }
  599. return $this->classes['theme_updater'];
  600. }
  601. /**
  602. * @since 2.0
  603. */
  604. function ajax_init() {
  605. new um\core\AJAX_Common();
  606. }
  607. /**
  608. * @since 2.0.30
  609. */
  610. function admin_ajax_hooks() {
  611. if ( empty( $this->classes['admin_ajax_hooks'] ) ) {
  612. $this->classes['admin_ajax_hooks'] = new um\admin\core\Admin_Ajax_Hooks();
  613. }
  614. return $this->classes['admin_ajax_hooks'];
  615. }
  616. /**
  617. * @since 2.0
  618. *
  619. * @return um\admin\Admin()
  620. */
  621. function admin() {
  622. if ( empty( $this->classes['admin'] ) ) {
  623. $this->classes['admin'] = new um\admin\Admin();
  624. }
  625. return $this->classes['admin'];
  626. }
  627. /**
  628. * @since 2.0
  629. *
  630. * @return um\admin\core\Admin_Menu()
  631. */
  632. function admin_menu() {
  633. if ( empty( $this->classes['admin_menu'] ) ) {
  634. $this->classes['admin_menu'] = new um\admin\core\Admin_Menu();
  635. }
  636. return $this->classes['admin_menu'];
  637. }
  638. /**
  639. * @since 2.0.26
  640. *
  641. * @return um\admin\core\Admin_Navmenu()
  642. */
  643. function admin_navmenu() {
  644. if ( empty( $this->classes['admin_navmenu'] ) ) {
  645. $this->classes['admin_navmenu'] = new um\admin\core\Admin_Navmenu();
  646. }
  647. return $this->classes['admin_navmenu'];
  648. }
  649. /**
  650. * @since 2.0
  651. *
  652. * @return um\admin\core\Admin_Settings()
  653. */
  654. function admin_settings() {
  655. if ( empty( $this->classes['admin_settings'] ) ) {
  656. $this->classes['admin_settings'] = new um\admin\core\Admin_Settings();
  657. }
  658. return $this->classes['admin_settings'];
  659. }
  660. /**
  661. * @since 2.0
  662. *
  663. * @return um\admin\core\Admin_Upgrade()
  664. */
  665. function admin_upgrade() {
  666. if ( empty( $this->classes['admin_upgrade'] ) ) {
  667. $this->classes['admin_upgrade'] = um\admin\core\Admin_Upgrade::instance();
  668. //$this->classes['admin_upgrade'] = new um\admin\core\Admin_Upgrade();
  669. }
  670. return $this->classes['admin_upgrade'];
  671. }
  672. /**
  673. * GDPR privacy policy
  674. *
  675. * @since 2.0.14
  676. *
  677. * @return bool|um\admin\core\Admin_GDPR()
  678. */
  679. function admin_gdpr() {
  680. global $wp_version;
  681. if ( version_compare( $wp_version, '4.9.6', '<' ) ) {
  682. return false;
  683. }
  684. if ( empty( $this->classes['admin_gdpr'] ) ) {
  685. $this->classes['admin_gdpr'] = new um\admin\core\Admin_GDPR();
  686. }
  687. return $this->classes['admin_gdpr'];
  688. }
  689. /**
  690. * GDPR privacy policy
  691. *
  692. * @since 2.0.14
  693. *
  694. * @return bool|um\core\GDPR()
  695. */
  696. function gdpr() {
  697. global $wp_version;
  698. if ( version_compare( $wp_version, '4.9.6', '<' ) ) {
  699. return false;
  700. }
  701. if ( empty( $this->classes['gdpr'] ) ) {
  702. $this->classes['gdpr'] = new um\core\GDPR();
  703. }
  704. return $this->classes['gdpr'];
  705. }
  706. /**
  707. * @since 2.0
  708. *
  709. * @return um\admin\core\Admin_Columns()
  710. */
  711. function columns() {
  712. if ( empty( $this->classes['admin_columns'] ) ) {
  713. $this->classes['admin_columns'] = new um\admin\core\Admin_Columns();
  714. }
  715. return $this->classes['admin_columns'];
  716. }
  717. /**
  718. * @since 2.0
  719. *
  720. * @return um\admin\core\Admin_Enqueue()
  721. */
  722. function admin_enqueue() {
  723. if ( empty( $this->classes['admin_enqueue'] ) ) {
  724. $this->classes['admin_enqueue'] = new um\admin\core\Admin_Enqueue();
  725. }
  726. return $this->classes['admin_enqueue'];
  727. }
  728. /**
  729. * @since 2.0
  730. *
  731. * @return um\admin\core\Admin_Metabox()
  732. */
  733. function metabox() {
  734. if ( empty( $this->classes['admin_metabox'] ) ) {
  735. $this->classes['admin_metabox'] = new um\admin\core\Admin_Metabox();
  736. }
  737. return $this->classes['admin_metabox'];
  738. }
  739. /**
  740. * @since 2.0
  741. *
  742. * @return um\admin\core\Admin_Users()
  743. */
  744. function users() {
  745. if ( empty( $this->classes['admin_users'] ) ) {
  746. $this->classes['admin_users'] = new um\admin\core\Admin_Users();
  747. }
  748. return $this->classes['admin_users'];
  749. }
  750. /**
  751. * @since 2.0
  752. *
  753. * @return um\admin\core\Admin_Builder()
  754. */
  755. function builder() {
  756. if ( empty( $this->classes['admin_builder'] ) ) {
  757. $this->classes['admin_builder'] = new um\admin\core\Admin_Builder();
  758. }
  759. return $this->classes['admin_builder'];
  760. }
  761. /**
  762. * @since 2.0
  763. *
  764. * @return um\admin\core\Admin_DragDrop()
  765. */
  766. function dragdrop() {
  767. if ( empty( $this->classes['admin_dragdrop'] ) ) {
  768. $this->classes['admin_dragdrop'] = new um\admin\core\Admin_DragDrop();
  769. }
  770. return $this->classes['admin_dragdrop'];
  771. }
  772. /**
  773. * @since 2.0
  774. *
  775. * @param bool|array $data
  776. * @return um\admin\core\Admin_Forms()
  777. */
  778. function admin_forms( $data = false ) {
  779. if ( ! isset( $this->classes[ 'admin_forms_' . $data['class'] ] ) || empty( $this->classes[ 'admin_forms_' . $data['class'] ] ) ) {
  780. $this->classes[ 'admin_forms_' . $data['class'] ] = new um\admin\core\Admin_Forms( $data );
  781. }
  782. return $this->classes[ 'admin_forms_' . $data['class'] ];
  783. }
  784. /**
  785. * @since 2.0
  786. *
  787. * @param bool|array $data
  788. * @return um\admin\core\Admin_Forms_Settings()
  789. */
  790. function admin_forms_settings( $data = false ) {
  791. if ( ! isset( $this->classes[ 'admin_forms_settings_' . $data['class'] ] ) || empty( $this->classes[ 'admin_forms_settings_' . $data['class'] ] ) ) {
  792. $this->classes[ 'admin_forms_settings_' . $data['class'] ] = new um\admin\core\Admin_Forms_Settings( $data );
  793. }
  794. return $this->classes[ 'admin_forms_settings_' . $data['class'] ];
  795. }
  796. /**
  797. * @since 2.0.34
  798. *
  799. * @return um\Extensions
  800. */
  801. function extensions() {
  802. if ( empty( $this->classes['extensions'] ) ) {
  803. $this->classes['extensions'] = new um\Extensions();
  804. }
  805. return $this->classes['extensions'];
  806. }
  807. /**
  808. * @since 2.0
  809. *
  810. * @return um\Dependencies
  811. */
  812. function dependencies() {
  813. if ( empty( $this->classes['dependencies'] ) ) {
  814. $this->classes['dependencies'] = new um\Dependencies();
  815. }
  816. return $this->classes['dependencies'];
  817. }
  818. /**
  819. * @since 2.0
  820. *
  821. * @return um\Config
  822. */
  823. function config() {
  824. if ( empty( $this->classes['config'] ) ) {
  825. $this->classes['config'] = new um\Config();
  826. }
  827. return $this->classes['config'];
  828. }
  829. /**
  830. * @since 2.0
  831. *
  832. * @return um\core\rest\API_v1|um\core\rest\API_v2
  833. */
  834. function rest_api() {
  835. $api_version = $this->options()->get( 'rest_api_version' );
  836. if ( empty( $this->classes['rest_api'] ) ) {
  837. if ( '1.0' === $api_version ) {
  838. $this->classes['rest_api'] = new um\core\rest\API_v1();
  839. } elseif ( '2.0' === $api_version ) {
  840. $this->classes['rest_api'] = new um\core\rest\API_v2();
  841. } else {
  842. $this->classes['rest_api'] = new um\core\rest\API_v1();
  843. }
  844. }
  845. return $this->classes['rest_api'];
  846. }
  847. /**
  848. * @since 2.0
  849. *
  850. * @return um\core\Rewrite
  851. */
  852. function rewrite() {
  853. if ( empty( $this->classes['rewrite'] ) ) {
  854. $this->classes['rewrite'] = new um\core\Rewrite();
  855. }
  856. return $this->classes['rewrite'];
  857. }
  858. /**
  859. * @since 2.0
  860. *
  861. * @return um\core\Setup
  862. */
  863. function setup() {
  864. if ( empty( $this->classes['setup'] ) ) {
  865. $this->classes['setup'] = new um\core\Setup();
  866. }
  867. return $this->classes['setup'];
  868. }
  869. /**
  870. * @since 2.0
  871. *
  872. * @return um\core\FontIcons
  873. */
  874. function fonticons() {
  875. if ( empty( $this->classes['fonticons'] ) ) {
  876. $this->classes['fonticons'] = new um\core\FontIcons();
  877. }
  878. return $this->classes['fonticons'];
  879. }
  880. /**
  881. * @since 2.0
  882. *
  883. * @return um\core\Login
  884. */
  885. function login() {
  886. if ( empty( $this->classes['login'] ) ) {
  887. $this->classes['login'] = new um\core\Login();
  888. }
  889. return $this->classes['login'];
  890. }
  891. /**
  892. * @since 2.0
  893. *
  894. * @return um\core\Register
  895. */
  896. function register() {
  897. if ( empty( $this->classes['register'] ) ) {
  898. $this->classes['register'] = new um\core\Register();
  899. }
  900. return $this->classes['register'];
  901. }
  902. /**
  903. * @since 2.0
  904. *
  905. * @return um\core\Enqueue
  906. */
  907. function enqueue() {
  908. if ( empty( $this->classes['enqueue'] ) ) {
  909. $this->classes['enqueue'] = new um\core\Enqueue();
  910. }
  911. return $this->classes['enqueue'];
  912. }
  913. /**
  914. * @since 2.0
  915. *
  916. * @return um\core\Shortcodes
  917. */
  918. function shortcodes() {
  919. if ( empty( $this->classes['shortcodes'] ) ) {
  920. $this->classes['shortcodes'] = new um\core\Shortcodes();
  921. }
  922. return $this->classes['shortcodes'];
  923. }
  924. /**
  925. * @since 2.0
  926. *
  927. * @return um\core\Account
  928. */
  929. function account() {
  930. if ( empty( $this->classes['account'] ) ) {
  931. $this->classes['account'] = new um\core\Account();
  932. }
  933. return $this->classes['account'];
  934. }
  935. /**
  936. * @since 2.0
  937. *
  938. * @return um\core\Password
  939. */
  940. function password() {
  941. if ( empty( $this->classes['password'] ) ) {
  942. $this->classes['password'] = new um\core\Password();
  943. }
  944. return $this->classes['password'];
  945. }
  946. /**
  947. * @since 2.0
  948. *
  949. * @return um\core\Form
  950. */
  951. function form() {
  952. if ( empty( $this->classes['form'] ) ) {
  953. $this->classes['form'] = new um\core\Form();
  954. }
  955. return $this->classes['form'];
  956. }
  957. /**
  958. * @since 2.0
  959. *
  960. * @return um\core\Fields
  961. */
  962. function fields() {
  963. if ( empty( $this->classes['fields'] ) ) {
  964. $this->classes['fields'] = new um\core\Fields();
  965. }
  966. return $this->classes['fields'];
  967. }
  968. /**
  969. * @since 2.0
  970. *
  971. * @return um\core\User
  972. */
  973. function user() {
  974. if ( empty( $this->classes['user'] ) ) {
  975. $this->classes['user'] = new um\core\User();
  976. }
  977. return $this->classes['user'];
  978. }
  979. /**
  980. * @since 2.0
  981. *
  982. * @return um\core\Roles_Capabilities
  983. */
  984. function roles() {
  985. if ( empty( $this->classes['roles'] ) ) {
  986. $this->classes['roles'] = new um\core\Roles_Capabilities();
  987. }
  988. return $this->classes['roles'];
  989. }
  990. /**
  991. * @since 2.0
  992. *
  993. * @return um\core\User_posts
  994. */
  995. function user_posts() {
  996. if ( empty( $this->classes['user_posts'] ) ) {
  997. $this->classes['user_posts'] = new um\core\User_posts();
  998. }
  999. return $this->classes['user_posts'];
  1000. }
  1001. /**
  1002. * @since 2.0
  1003. *
  1004. * @return um\core\Profile
  1005. */
  1006. function profile() {
  1007. if ( empty( $this->classes['profile'] ) ) {
  1008. $this->classes['profile'] = new um\core\Profile();
  1009. }
  1010. return $this->classes['profile'];
  1011. }
  1012. /**
  1013. * @since 2.0
  1014. *
  1015. * @return um\core\Query
  1016. */
  1017. function query() {
  1018. if ( empty( $this->classes['query'] ) ) {
  1019. $this->classes['query'] = new um\core\Query();
  1020. }
  1021. return $this->classes['query'];
  1022. }
  1023. /**
  1024. * @since 2.0
  1025. *
  1026. * @return um\core\Date_Time
  1027. */
  1028. function datetime() {
  1029. if ( empty( $this->classes['datetime'] ) ) {
  1030. $this->classes['datetime'] = new um\core\Date_Time();
  1031. }
  1032. return $this->classes['datetime'];
  1033. }
  1034. /**
  1035. * @since 2.0
  1036. *
  1037. * @return um\core\Builtin
  1038. */
  1039. function builtin() {
  1040. if ( empty( $this->classes['builtin'] ) ) {
  1041. $this->classes['builtin'] = new um\core\Builtin();
  1042. }
  1043. return $this->classes['builtin'];
  1044. }
  1045. /**
  1046. * @since 2.0
  1047. *
  1048. * @return um\core\Files
  1049. */
  1050. function files() {
  1051. if ( empty( $this->classes['files'] ) ) {
  1052. $this->classes['files'] = new um\core\Files();
  1053. }
  1054. return $this->classes['files'];
  1055. }
  1056. /**
  1057. * @since 2.0.21
  1058. *
  1059. * @return um\core\Uploader
  1060. */
  1061. function uploader() {
  1062. if ( empty( $this->classes['uploader'] ) ) {
  1063. $this->classes['uploader'] = new um\core\Uploader();
  1064. }
  1065. return $this->classes['uploader'];
  1066. }
  1067. /**
  1068. * @since 2.0
  1069. *
  1070. * @return um\core\Validation
  1071. */
  1072. function validation() {
  1073. if ( empty( $this->classes['validation'] ) ) {
  1074. $this->classes['validation'] = new um\core\Validation();
  1075. }
  1076. return $this->classes['validation'];
  1077. }
  1078. /**
  1079. * @since 2.0
  1080. *
  1081. * @return um\core\Access
  1082. */
  1083. function access() {
  1084. if ( empty( $this->classes['access'] ) ) {
  1085. $this->classes['access'] = new um\core\Access();
  1086. }
  1087. return $this->classes['access'];
  1088. }
  1089. /**
  1090. * @since 2.0
  1091. *
  1092. * @return um\core\Permalinks
  1093. */
  1094. function permalinks() {
  1095. if ( empty( $this->classes['permalinks'] ) ) {
  1096. $this->classes['permalinks'] = new um\core\Permalinks();
  1097. }
  1098. return $this->classes['permalinks'];
  1099. }
  1100. /**
  1101. * @since 2.0
  1102. *
  1103. * @return um\core\Mail
  1104. */
  1105. function mail() {
  1106. if ( empty( $this->classes['mail'] ) ) {
  1107. $this->classes['mail'] = new um\core\Mail();
  1108. }
  1109. return $this->classes['mail'];
  1110. }
  1111. /**
  1112. * @deprecated 2.1.0
  1113. *
  1114. * @since 2.0
  1115. *
  1116. * @return um\core\Members
  1117. */
  1118. function members() {
  1119. um_deprecated_function( 'UM()->members()', '2.1.0', 'UM()->member_directory()' );
  1120. if ( empty( $this->classes['members'] ) ) {
  1121. $this->classes['members'] = new um\core\Members();
  1122. }
  1123. return $this->classes['members'];
  1124. }
  1125. /**
  1126. * @since 2.0
  1127. *
  1128. * @return um\core\Logout
  1129. */
  1130. function logout() {
  1131. if ( empty( $this->classes['logout'] ) ) {
  1132. $this->classes['logout'] = new um\core\Logout();
  1133. }
  1134. return $this->classes['logout'];
  1135. }
  1136. /**
  1137. * @since 2.0
  1138. *
  1139. * @return um\core\Modal
  1140. */
  1141. function modal() {
  1142. if ( empty( $this->classes['modal'] ) ) {
  1143. $this->classes['modal'] = new um\core\Modal();
  1144. }
  1145. return $this->classes['modal'];
  1146. }
  1147. /**
  1148. * @since 2.0
  1149. *
  1150. * @return um\core\Cron
  1151. */
  1152. function cron() {
  1153. if ( empty( $this->classes['cron'] ) ) {
  1154. $this->classes['cron'] = new um\core\Cron();
  1155. }
  1156. return $this->classes['cron'];
  1157. }
  1158. /**
  1159. * @since 2.0
  1160. *
  1161. * @return um\core\Templates
  1162. */
  1163. function templates() {
  1164. if ( empty( $this->classes['templates'] ) ) {
  1165. $this->classes['templates'] = new um\core\Templates();
  1166. }
  1167. return $this->classes['templates'];
  1168. }
  1169. /**
  1170. * @since 2.0
  1171. *
  1172. * @return um\lib\mobiledetect\Um_Mobile_Detect
  1173. */
  1174. function mobile() {
  1175. if ( empty( $this->classes['mobile'] ) ) {
  1176. $this->classes['mobile'] = new um\lib\mobiledetect\Um_Mobile_Detect();
  1177. }
  1178. return $this->classes['mobile'];
  1179. }
  1180. /**
  1181. * @since 2.0.44
  1182. *
  1183. * @return um\core\Multisite
  1184. */
  1185. function multisite() {
  1186. if ( empty( $this->classes['multisite'] ) ) {
  1187. $this->classes['multisite'] = new um\core\Multisite();
  1188. }
  1189. return $this->classes['multisite'];
  1190. }
  1191. /**
  1192. * Include files with hooked filters/actions
  1193. *
  1194. * @since 2.0
  1195. */
  1196. function init() {
  1197. ob_start();
  1198. require_once 'core/um-actions-form.php';
  1199. require_once 'core/um-actions-access.php';
  1200. require_once 'core/um-actions-wpadmin.php';
  1201. require_once 'core/um-actions-core.php';
  1202. require_once 'core/um-actions-ajax.php';
  1203. require_once 'core/um-actions-login.php';
  1204. require_once 'core/um-actions-register.php';
  1205. require_once 'core/um-actions-profile.php';
  1206. require_once 'core/um-actions-account.php';
  1207. require_once 'core/um-actions-global.php';
  1208. require_once 'core/um-actions-user.php';
  1209. require_once 'core/um-actions-save-profile.php';
  1210. require_once 'core/um-actions-misc.php';
  1211. require_once 'core/um-filters-login.php';
  1212. require_once 'core/um-filters-fields.php';
  1213. require_once 'core/um-filters-files.php';
  1214. require_once 'core/um-filters-navmenu.php';
  1215. require_once 'core/um-filters-avatars.php';
  1216. require_once 'core/um-filters-user.php';
  1217. require_once 'core/um-filters-profile.php';
  1218. require_once 'core/um-filters-account.php';
  1219. require_once 'core/um-filters-misc.php';
  1220. require_once 'core/um-filters-commenting.php';
  1221. }
  1222. /**
  1223. * Init UM widgets
  1224. *
  1225. * @since 2.0
  1226. */
  1227. function widgets_init() {
  1228. register_widget( 'um\widgets\UM_Search_Widget' );
  1229. }
  1230. }
  1231. }
  1232. /**
  1233. * Function for calling UM methods and variables
  1234. *
  1235. * @since 2.0
  1236. *
  1237. * @return UM
  1238. */
  1239. function UM() {
  1240. return UM::instance();
  1241. }
  1242. // Global for backwards compatibility.
  1243. $GLOBALS['ultimatemember'] = UM();