From 304845b255c46d83acacb10376175b93d451d01e Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Wed, 28 Nov 2018 10:19:20 +0200 Subject: [PATCH] - fixed dynamic profile title; - removed deprecated router class; --- includes/core/class-ajax-common.php | 19 ----- includes/core/class-common.php | 29 ------- includes/core/class-rewrite.php | 3 - includes/core/class-router.php | 115 --------------------------- includes/core/um-filters-profile.php | 20 ++--- 5 files changed, 10 insertions(+), 176 deletions(-) delete mode 100644 includes/core/class-router.php diff --git a/includes/core/class-ajax-common.php b/includes/core/class-ajax-common.php index b1faa596..5d70291d 100644 --- a/includes/core/class-ajax-common.php +++ b/includes/core/class-ajax-common.php @@ -20,7 +20,6 @@ if ( ! class_exists( 'um\core\AJAX_Common' ) ) { function __construct() { // UM_EVENT => nopriv $ajax_actions = array( - 'router' => false ); foreach ( $ajax_actions as $action => $nopriv ) { @@ -54,24 +53,6 @@ if ( ! class_exists( 'um\core\AJAX_Common' ) ) { add_action( 'wp_ajax_nopriv_um_resize_image', array( UM()->files(), 'ajax_resize_image' ) ); add_action( 'wp_ajax_um_resize_image', array( UM()->files(), 'ajax_resize_image' ) ); - - - /** - * Fallback for ajax urls - * @uses action hooks: wp_head, admin_head - */ - //add_action( 'wp_head', array( $this, 'ultimatemember_ajax_urls' ) ); - //add_action( 'admin_head', array( $this, 'ultimatemember_ajax_urls' ) ); - - } - - - /** - * Router method - */ - function router() { - $router = new Router(); - $router->backend_requests(); } } } \ No newline at end of file diff --git a/includes/core/class-common.php b/includes/core/class-common.php index b20eac5d..90ac6d36 100644 --- a/includes/core/class-common.php +++ b/includes/core/class-common.php @@ -18,8 +18,6 @@ if ( ! class_exists( 'um\core\Common' ) ) { function __construct() { add_action( 'init', array( &$this, 'create_post_types' ), 1 ); - add_filter( 'posts_request', array( &$this, 'um_query_pages' ) ); - add_filter( 'body_class', array( &$this, 'remove_admin_bar' ), 1000, 1 ); } @@ -110,33 +108,6 @@ if ( ! class_exists( 'um\core\Common' ) ) { } } - - - /** - * Check query string on 'posts_request' for our pages - * - * @param string $q - * - * @return string - */ - public function um_query_pages( $q ) { - global $wp_query; - - //We need main query - if ( isset( $wp_query->request ) && $q == $wp_query->request ) { - - if ( ! empty( $wp_query->query_vars['um_page'] ) ) { - - if ( 'api' == $wp_query->query_vars['um_page'] ) { - $router = new Router(); - $router->frontend_requests(); - } - } - - } - - return $q; - } } } \ No newline at end of file diff --git a/includes/core/class-rewrite.php b/includes/core/class-rewrite.php index 0dc84e11..bbd36640 100644 --- a/includes/core/class-rewrite.php +++ b/includes/core/class-rewrite.php @@ -46,8 +46,6 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) { $public_query_vars[] = 'um_action'; $public_query_vars[] = 'um_field'; $public_query_vars[] = 'um_form'; - $public_query_vars[] = 'um_resource'; - $public_query_vars[] = 'um_method'; $public_query_vars[] = 'um_verify'; return $public_query_vars; @@ -64,7 +62,6 @@ if ( ! class_exists( 'um\core\Rewrite' ) ) { function _add_rewrite_rules( $rules ) { $newrules = array(); - $newrules['um-api/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?um_page=api&um_action=$matches[1]&um_resource=$matches[2]&um_method=$matches[3]&um_verify=$matches[4]'; $newrules['um-download/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?um_action=download&um_form=$matches[1]&um_field=$matches[2]&um_user=$matches[3]&um_verify=$matches[4]'; if ( isset( UM()->config()->permalinks['user'] ) ) { diff --git a/includes/core/class-router.php b/includes/core/class-router.php deleted file mode 100644 index 50f25c2d..00000000 --- a/includes/core/class-router.php +++ /dev/null @@ -1,115 +0,0 @@ -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'] - ) ); - }*/ - } - - - /** - * Request process - * - * @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; - } - - - /** - * Run frontend process - */ - 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' ) ); - } - } - - } -} \ No newline at end of file diff --git a/includes/core/um-filters-profile.php b/includes/core/um-filters-profile.php index 6a94e1c9..ae7296ea 100644 --- a/includes/core/um-filters-profile.php +++ b/includes/core/um-filters-profile.php @@ -42,25 +42,25 @@ add_filter('pre_get_document_title', 'um_dynamic_user_profile_pagetitle', 100000 * @return string */ function um_dynamic_user_profile_title( $title, $id = '' ) { - - if( is_admin() ){ + if ( is_admin() ) { return $title; } - if ( $id == UM()->config()->permalinks['user'] && in_the_loop() ) { - if ( um_is_core_page('user') && um_get_requested_user() ) { - $title = um_get_display_name( um_get_requested_user() ); - } else if ( um_is_core_page('user') && is_user_logged_in() ) { - $title = um_get_display_name( get_current_user_id() ); + if ( um_is_core_page('user') ) { + if ( $id == UM()->config()->permalinks['user'] && in_the_loop() ) { + if ( um_get_requested_user() ) { + $title = um_get_display_name( um_get_requested_user() ); + } elseif ( is_user_logged_in() ) { + $title = um_get_display_name( get_current_user_id() ); + } } } - - if( ! function_exists('utf8_decode') ){ + if ( ! function_exists( 'utf8_decode' ) ) { return $title; } - return (strlen($title)!==strlen(utf8_decode($title))) ? $title : utf8_encode($title); + return ( strlen( $title ) !== strlen( utf8_decode( $title ) ) ) ? $title : utf8_encode( $title ); } add_filter( 'the_title', 'um_dynamic_user_profile_title', 100000, 2 );