Files
ultimatemember/includes/core/class-router.php
T
nikitozzzzzzz 9e53314c3a !!! IMPORTANT 2.0 version before upgrade please run full backup of your site !!!
- new code structure, optimized for next development;
  - created spl_autoloader for remove includes;
  - UM classes with namespaces;
  - deprecated global $ultimatemember; variable (use UM() instead);
- new UM/WP roles logic;
- new settings class and logic (deprecated Redux framework, deprecated some old options, added some new options);
- new dependencies class for extensions;
- WP native styles for backend fields;
- new upgrades and license activations for extensions;
- new logic form backend forms and fields;
- created uninstall.php file for delete permanently all UM settings;
- optimized registration/upgrade profile process;

Deprecated Hooks:

um_new_user_registration_plain
um_user_registration_extra_hook
um_add_user_frontend
um_post_registration_global_hook
um_admin_extend_directory_options_general (was action...will be filter)
2017-07-26 14:57:52 +03:00

103 lines
3.6 KiB
PHP

<?php
namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Router' ) ) {
class Router {
/**
*
*/
function backend_requests() {
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
$user_id = get_current_user_id();
if ( empty( $_REQUEST['um_action'] ) )
exit( __( 'Wrong action', 'ultimate-member' ) );
if ( empty( $_REQUEST['um_resource'] ) )
exit( __( 'Wrong resource', 'ultimate-member' ) );
if ( $_REQUEST['um_action'] == 'route' )
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_resource'] . $_REQUEST['um_method'] );
else
$verify = wp_verify_nonce( $_REQUEST['um_verify'], $ip . $user_id . $_REQUEST['um_action'] . $_REQUEST['um_resource'] );
if ( empty( $verify ) )
exit( __( 'Wrong nonce', 'ultimate-member' ) );
$this->request_process( array(
'route' => $_REQUEST['um_resource'],
'method' => $_REQUEST['um_method']
) );
/*if ($_REQUEST['um_action'] == 'download' || $_REQUEST['um_action'] == 'view') {
WO()->downloader()->set_type( $_REQUEST['um_action'] )->process( array(
'id' => $_REQUEST['um_id'],
'resource' => $_REQUEST['um_resource'],
'action' => $_REQUEST['um_action']
) );
} else if ($_REQUEST['um_action'] == 'route') {
$this->request_process( array(
'route' => $_REQUEST['um_resource'],
'method' => $_REQUEST['um_method']
) );
}*/
}
/**
* @param $params array
* @return bool
*/
function request_process( $params ) {
if ( empty( $params['route'] ) || empty( $params['method'] ) )
return false;
$route = str_replace( array( '!', '/' ), '\\', $params['route'] );
if ( ! class_exists( $route ) )
return false;
if ( method_exists( $route, 'instance' ) )
$object = $route::instance();
else
$object = new $route();
if ( ! method_exists( $object, $params['method'] ) )
return false;
call_user_func( array( &$object, $params['method'] ) );
return true;
}
function frontend_requests() {
$ip = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : '';
$user_id = get_current_user_id();
if ( ! get_query_var( 'um_action' ) )
exit( __( 'Wrong action', 'ultimate-member' ) );
if ( ! get_query_var( 'um_resource' ) )
exit( __( 'Wrong resource', 'ultimate-member' ) );
$verify = false;
if ( get_query_var( 'um_action' ) == 'route' )
$verify = wp_verify_nonce( get_query_var( 'um_verify' ), $ip . $user_id . get_query_var( 'um_resource' ) . get_query_var( 'um_method' ) );
if ( $verify ) {
if ( get_query_var( 'um_action' ) == 'route' ) {
$this->request_process( array(
'route' => get_query_var( 'um_resource' ),
'method' => get_query_var( 'um_method' )
) );
}
} else {
exit( __( 'Wrong nonce', 'ultimate-member' ) );
}
}
}
}