mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- conditional logic fixed;
- some code optimization and documentation; - fixed conflict with WP Fusion;
This commit is contained in:
@@ -5,129 +5,151 @@ namespace um\admin\core;
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! class_exists( 'Admin_Columns' ) ) {
|
||||
class Admin_Columns {
|
||||
|
||||
function __construct() {
|
||||
|
||||
$this->slug = 'ultimatemember';
|
||||
|
||||
add_filter('manage_edit-um_form_columns', array(&$this, 'manage_edit_um_form_columns') );
|
||||
add_action('manage_um_form_posts_custom_column', array(&$this, 'manage_um_form_posts_custom_column'), 10, 3);
|
||||
|
||||
add_filter('manage_edit-um_directory_columns', array(&$this, 'manage_edit_um_directory_columns') );
|
||||
add_action('manage_um_directory_posts_custom_column', array(&$this, 'manage_um_directory_posts_custom_column'), 10, 3);
|
||||
|
||||
add_filter('post_row_actions', array(&$this, 'post_row_actions'), 99, 2);
|
||||
|
||||
// Add a post display state for special UM pages.
|
||||
add_filter( 'display_post_states', array( &$this, 'add_display_post_states' ), 10, 2 );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @custom row actions
|
||||
***/
|
||||
function post_row_actions( $actions, $post ) {
|
||||
//check for your post type
|
||||
if ( $post->post_type == "um_form" ) {
|
||||
$actions['um_duplicate'] = '<a href="' . $this->duplicate_uri( $post->ID ) . '">' . __('Duplicate','ultimate-member') . '</a>';
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @duplicate a form
|
||||
***/
|
||||
function duplicate_uri( $id ) {
|
||||
$url = add_query_arg('um_adm_action', 'duplicate_form', admin_url('edit.php?post_type=um_form') );
|
||||
$url = add_query_arg('post_id', $id, $url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Custom columns for Form
|
||||
***/
|
||||
function manage_edit_um_form_columns( $columns ) {
|
||||
|
||||
$new_columns['cb'] = '<input type="checkbox" />';
|
||||
$new_columns['title'] = __( 'Title', 'ulitmatemember' );
|
||||
$new_columns['id'] = __('ID', 'ulitmatemember' );
|
||||
$new_columns['mode'] = __( 'Type', 'ulitmatemember' );
|
||||
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmatemember' );
|
||||
$new_columns['date'] = __( 'Date', 'ulitmatemember' );
|
||||
|
||||
return $new_columns;
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Custom columns for Directory
|
||||
***/
|
||||
function manage_edit_um_directory_columns( $columns ) {
|
||||
|
||||
$new_columns['cb'] = '<input type="checkbox" />';
|
||||
|
||||
$new_columns['title'] = __( 'Title', 'ultimate-member' );
|
||||
$new_columns['id'] = __( 'ID', 'ultimate-member' );
|
||||
$new_columns['shortcode'] = __( 'Shortcode', 'ultimate-member' );
|
||||
$new_columns['date'] = __( 'Date', 'ultimate-member' );
|
||||
|
||||
return $new_columns;
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Display cusom columns for Form
|
||||
***/
|
||||
function manage_um_form_posts_custom_column( $column_name, $id ) {
|
||||
|
||||
switch ( $column_name ) {
|
||||
|
||||
case 'id':
|
||||
echo '<span class="um-admin-number">'.$id.'</span>';
|
||||
break;
|
||||
|
||||
case 'shortcode':
|
||||
echo UM()->shortcodes()->get_shortcode( $id );
|
||||
break;
|
||||
|
||||
case 'mode':
|
||||
$mode = UM()->query()->get_attr( 'mode', $id );
|
||||
echo UM()->form()->display_form_type( $mode, $id );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Display cusom columns for Directory
|
||||
***/
|
||||
function manage_um_directory_posts_custom_column($column_name, $id) {
|
||||
global $wpdb;
|
||||
|
||||
switch ($column_name) {
|
||||
|
||||
case 'id':
|
||||
echo '<span class="um-admin-number">'.$id.'</span>';
|
||||
break;
|
||||
|
||||
case 'shortcode':
|
||||
echo UM()->shortcodes()->get_shortcode( $id );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Class Admin_Columns
|
||||
* @package um\admin\core
|
||||
*/
|
||||
class Admin_Columns {
|
||||
|
||||
|
||||
/**
|
||||
* Add a post display state for special UM pages in the page list table.
|
||||
*
|
||||
* @param array $post_states An array of post display states.
|
||||
* @param \WP_Post $post The current post object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
* Admin_Columns constructor.
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
add_filter( 'manage_edit-um_form_columns', array( &$this, 'manage_edit_um_form_columns' ) );
|
||||
add_action( 'manage_um_form_posts_custom_column', array( &$this, 'manage_um_form_posts_custom_column' ), 10, 3 );
|
||||
|
||||
add_filter( 'manage_edit-um_directory_columns', array( &$this, 'manage_edit_um_directory_columns' ) );
|
||||
add_action( 'manage_um_directory_posts_custom_column', array( &$this, 'manage_um_directory_posts_custom_column' ), 10, 3 );
|
||||
|
||||
add_filter( 'post_row_actions', array( &$this, 'post_row_actions' ), 99, 2 );
|
||||
|
||||
// Add a post display state for special UM pages.
|
||||
add_filter( 'display_post_states', array( &$this, 'add_display_post_states' ), 10, 2 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom row actions
|
||||
*
|
||||
* @param array $actions
|
||||
* @param \WP_Post $post
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function post_row_actions( $actions, $post ) {
|
||||
//check for your post type
|
||||
if ( $post->post_type == "um_form" ) {
|
||||
$actions['um_duplicate'] = '<a href="' . $this->duplicate_uri( $post->ID ) . '">' . __( 'Duplicate', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Duplicate a form
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function duplicate_uri( $id ) {
|
||||
$url = add_query_arg('um_adm_action', 'duplicate_form', admin_url('edit.php?post_type=um_form') );
|
||||
$url = add_query_arg('post_id', $id, $url);
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom columns for Form
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function manage_edit_um_form_columns( $columns ) {
|
||||
$new_columns['cb'] = '<input type="checkbox" />';
|
||||
$new_columns['title'] = __( 'Title', 'ulitmatemember' );
|
||||
$new_columns['id'] = __('ID', 'ulitmatemember' );
|
||||
$new_columns['mode'] = __( 'Type', 'ulitmatemember' );
|
||||
$new_columns['shortcode'] = __( 'Shortcode', 'ulitmatemember' );
|
||||
$new_columns['date'] = __( 'Date', 'ulitmatemember' );
|
||||
|
||||
return $new_columns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom columns for Directory
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function manage_edit_um_directory_columns( $columns ) {
|
||||
$new_columns['cb'] = '<input type="checkbox" />';
|
||||
$new_columns['title'] = __( 'Title', 'ultimate-member' );
|
||||
$new_columns['id'] = __( 'ID', 'ultimate-member' );
|
||||
$new_columns['shortcode'] = __( 'Shortcode', 'ultimate-member' );
|
||||
$new_columns['date'] = __( 'Date', 'ultimate-member' );
|
||||
|
||||
return $new_columns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display custom columns for Form
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param int $id
|
||||
*/
|
||||
function manage_um_form_posts_custom_column( $column_name, $id ) {
|
||||
switch ( $column_name ) {
|
||||
case 'id':
|
||||
echo '<span class="um-admin-number">'.$id.'</span>';
|
||||
break;
|
||||
|
||||
case 'shortcode':
|
||||
echo UM()->shortcodes()->get_shortcode( $id );
|
||||
break;
|
||||
|
||||
case 'mode':
|
||||
$mode = UM()->query()->get_attr( 'mode', $id );
|
||||
echo UM()->form()->display_form_type( $mode, $id );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display cusom columns for Directory
|
||||
*
|
||||
* @param string $column_name
|
||||
* @param int $id
|
||||
*/
|
||||
function manage_um_directory_posts_custom_column( $column_name, $id ) {
|
||||
switch ( $column_name ) {
|
||||
case 'id':
|
||||
echo '<span class="um-admin-number">'.$id.'</span>';
|
||||
break;
|
||||
case 'shortcode':
|
||||
echo UM()->shortcodes()->get_shortcode( $id );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a post display state for special UM pages in the page list table.
|
||||
*
|
||||
* @param array $post_states An array of post display states.
|
||||
* @param \WP_Post $post The current post object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function add_display_post_states( $post_states, $post ) {
|
||||
|
||||
foreach ( UM()->config()->core_pages as $page_key => $page_value ) {
|
||||
@@ -141,5 +163,5 @@ if ( ! class_exists( 'Admin_Columns' ) ) {
|
||||
return $post_states;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user