mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- 2.0.1 version;
- small code optimization; - fix for update user profile role change;
This commit is contained in:
@@ -21,6 +21,29 @@ if ( ! class_exists( 'Admin' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if current page load UM post type
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_plugin_post_type() {
|
||||
if ( isset( $_REQUEST['post_type'] ) ) {
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
if ( in_array( $post_type, array( 'um_form','um_directory' ) ) ) {
|
||||
return true;
|
||||
}
|
||||
} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array( $post_type, array( 'um_form', 'um_directory' ) ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if plugin is installed with correct folder
|
||||
*/
|
||||
|
||||
@@ -51,26 +51,24 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
|
||||
/***
|
||||
*** @enter title placeholder
|
||||
***/
|
||||
function enter_title_here( $title ){
|
||||
function enter_title_here( $title ) {
|
||||
$screen = get_current_screen();
|
||||
if ( 'um_directory' == $screen->post_type ){
|
||||
$title = 'e.g. Member Directory';
|
||||
}
|
||||
if ( 'um_role' == $screen->post_type ){
|
||||
$title = 'e.g. Community Member';
|
||||
}
|
||||
if ( 'um_form' == $screen->post_type ){
|
||||
$title = 'e.g. New Registration Form';
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Runs on admin head
|
||||
***/
|
||||
function admin_head(){
|
||||
|
||||
if ( $this->is_plugin_post_type() ){
|
||||
if ( UM()->admin()->is_plugin_post_type() ){
|
||||
|
||||
?>
|
||||
|
||||
@@ -87,25 +85,6 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @check that we're on a custom post type supported by UM
|
||||
***/
|
||||
function is_plugin_post_type(){
|
||||
if (isset($_REQUEST['post_type'])){
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
} else if ( isset($_REQUEST['action'] ) && $_REQUEST['action'] == 'edit') {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** @Load Form
|
||||
***/
|
||||
|
||||
@@ -44,44 +44,9 @@ if ( ! class_exists( 'Admin_Functions' ) ) {
|
||||
|
||||
}
|
||||
|
||||
if ($post_type == 'um_role') {
|
||||
|
||||
$messages['um_role'] = array(
|
||||
0 => '',
|
||||
1 => __('Role updated.'),
|
||||
2 => __('Custom field updated.'),
|
||||
3 => __('Custom field deleted.'),
|
||||
4 => __('Role updated.'),
|
||||
5 => isset($_GET['revision']) ? __('Role restored to revision.') : false,
|
||||
6 => __('Role created.'),
|
||||
7 => __('Role saved.'),
|
||||
8 => __('Role submitted.'),
|
||||
9 => __('Role scheduled.'),
|
||||
10=> __('Role draft updated.'),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @check that we're on a custom post type supported by UM
|
||||
***/
|
||||
function is_plugin_post_type(){
|
||||
if (isset($_REQUEST['post_type'])){
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
} else if ( isset($_REQUEST['action'] ) && $_REQUEST['action'] == 'edit') {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @gettext filters
|
||||
@@ -89,7 +54,7 @@ if ( ! class_exists( 'Admin_Functions' ) ) {
|
||||
function gettext($translation, $text, $domain) {
|
||||
global $post;
|
||||
//$screen = get_current_screen();
|
||||
if ( isset( $post->post_type ) && $this->is_plugin_post_type() ) {
|
||||
if ( isset( $post->post_type ) && UM()->admin()->is_plugin_post_type() ) {
|
||||
$translations = get_translations_for_domain( $domain);
|
||||
if ( $text == 'Publish') {
|
||||
return $translations->translate( 'Create' );
|
||||
|
||||
@@ -39,23 +39,6 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @check that we're on a custom post type supported by UM
|
||||
***/
|
||||
function is_plugin_post_type() {
|
||||
if (isset($_REQUEST['post_type'])){
|
||||
$post_type = $_REQUEST['post_type'];
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
} else if ( isset($_REQUEST['action'] ) && $_REQUEST['action'] == 'edit') {
|
||||
$post_type = get_post_type();
|
||||
if ( in_array($post_type, array('um_form','um_role','um_directory'))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Gets the role meta
|
||||
@@ -76,7 +59,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
***/
|
||||
function admin_head(){
|
||||
global $post;
|
||||
if ( $this->is_plugin_post_type() && isset($post->ID) ){
|
||||
if ( UM()->admin()->is_plugin_post_type() && isset($post->ID) ){
|
||||
$this->postmeta = $this->get_custom_post_meta($post->ID);
|
||||
}
|
||||
}
|
||||
@@ -767,46 +750,6 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @save role metabox
|
||||
***/
|
||||
/* function save_metabox_role( $post_id, $post ) {
|
||||
global $wpdb;
|
||||
|
||||
// validate nonce
|
||||
if ( !isset( $_POST['um_admin_save_metabox_role_nonce'] ) || !wp_verify_nonce( $_POST['um_admin_save_metabox_role_nonce'], basename( __FILE__ ) ) ) return $post_id;
|
||||
|
||||
// validate post type
|
||||
if ( $post->post_type != 'um_role' ) return $post_id;
|
||||
|
||||
// validate user
|
||||
$post_type = get_post_type_object( $post->post_type );
|
||||
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) return $post_id;
|
||||
|
||||
$where = array( 'ID' => $post_id );
|
||||
if (empty($_POST['post_title'])) $_POST['post_title'] = 'Role #'.$post_id;
|
||||
$wpdb->update( $wpdb->posts, array( 'post_title' => $_POST['post_title'], 'post_name' => sanitize_title( $_POST['post_title'] ) ), $where );
|
||||
|
||||
// save
|
||||
delete_post_meta( $post_id, '_um_can_view_roles' );
|
||||
delete_post_meta( $post_id, '_um_can_edit_roles' );
|
||||
delete_post_meta( $post_id, '_um_can_delete_roles' );
|
||||
|
||||
do_action('um_admin_before_saving_role_meta', $post_id );
|
||||
|
||||
do_action('um_admin_before_save_role', $post_id, $post );
|
||||
|
||||
foreach( $_POST as $k => $v ) {
|
||||
if (strstr($k, '_um_')){
|
||||
update_post_meta( $post_id, $k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
do_action('um_admin_after_editing_role', $post_id, $post);
|
||||
|
||||
do_action('um_admin_after_save_role', $post_id, $post );
|
||||
|
||||
}*/
|
||||
|
||||
/***
|
||||
*** @save form metabox
|
||||
|
||||
Reference in New Issue
Block a user