domain = Author_Profile_Widget_Config::DOMAIN;
}
/**
* widget
*/
public function widget() {
register_widget( 'Author_Profile_Widget_Profile' );
register_widget( 'Author_Profile_Widget_List' );
}
/**
* edit_user_profile
*/
public function edit_user_profile( $profileuser ) {
if ( !current_user_can( 'edit_users' ) )
return;
?>
domain ); ?>
domain . '_orderby';
$orderby = get_user_meta( $profileuser->data->ID, $orderbyncol, true );
$value = ( empty( $orderby ) ) ? 0 : $orderby;
wp_nonce_field( $this->domain . '_nonce', '_' . $this->domain . '_nonce', false );
?>
domain . '_nonce';
if ( ! isset( $_POST[$nonce_name] ) || ! wp_verify_nonce( $_POST[$nonce_name], $this->domain . '_nonce' ) )
return false;
$post = array();
$orderbyncol = $this->domain . '_orderby';
$orderby = 0;
if ( isset( $_POST[$orderbyncol] ) ) {
if ( preg_match( '/^\d*$/', $_POST[$orderbyncol] ) ) {
$orderby = $_POST[$orderbyncol];
}
}
update_user_meta( $user_id, $orderbyncol, $orderby );
}
/**
* extended_user_search
*/
public function extended_user_search( $user_query ) {
global $wpdb;
$_user_query = $user_query;
if ( isset( $user_query->query_vars['orderby'] ) && $user_query->query_vars['orderby'] === 'orderby' ) {
$user_query->query_from .= '
left join
(
SELECT user_id, meta_value FROM `' . _get_meta_table( 'user' ) . '`
WHERE meta_key = "' . $this->domain . '_orderby"
) as UD
on
`' . $wpdb->prefix . 'users`.ID = UD.user_id
';
if ( $user_query->query_vars['order'] == 'DESC' ) {
$user_query->query_orderby = 'ORDER BY CAST( UD.meta_value AS SIGNED ) DESC';
} else {
$user_query->query_orderby = 'ORDER BY CAST( UD.meta_value AS SIGNED ) IS NULL ASC, CAST( UD.meta_value AS SIGNED ) ASC';
}
}
return $user_query;
}
/**
* CSS適用
*/
public function wp_enqueue_script() {
$url = plugin_dir_url( __FILE__ ) . './css';
wp_enqueue_style( $this->domain . '-css', $url . '/author-profile-widget.css' );
}
}