| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpDeveloperModuleDevAdmin' ) ) : |
| 12 |
|
| 13 |
final class MywpDeveloperModuleDevAdmin extends MywpDeveloperAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'dev_admin'; |
| 16 |
|
| 17 |
static protected $priority = 20; |
| 18 |
|
| 19 |
static private $post_updated_messages = array(); |
| 20 |
|
| 21 |
static private $bulk_post_updated_messages = array(); |
| 22 |
|
| 23 |
protected static function after_init() { |
| 24 |
|
| 25 |
add_filter( 'post_updated_messages' , array( __CLASS__ , 'post_updated_messages' ) , 1000 ); |
| 26 |
|
| 27 |
add_filter( 'bulk_post_updated_messages' , array( __CLASS__ , 'bulk_post_updated_messages' ) , 1000 ); |
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
public static function post_updated_messages( $messages ) { |
| 32 |
|
| 33 |
global $typenow; |
| 34 |
|
| 35 |
if( empty( $typenow ) ) { |
| 36 |
|
| 37 |
return $messages; |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
if( isset( $messages[ $typenow ] ) ) { |
| 42 |
|
| 43 |
self::$post_updated_messages = $messages[ $typenow ]; |
| 44 |
|
| 45 |
} elseif( isset( $messages['post'] ) ) { |
| 46 |
|
| 47 |
self::$post_updated_messages = $messages[ 'post' ]; |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
return $messages; |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
public static function bulk_post_updated_messages( $bulk_messages ) { |
| 56 |
|
| 57 |
global $typenow; |
| 58 |
|
| 59 |
if( empty( $typenow ) ) { |
| 60 |
|
| 61 |
return $bulk_messages; |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
if( isset( $bulk_messages[ $typenow ] ) ) { |
| 66 |
|
| 67 |
self::$bulk_post_updated_messages = $bulk_messages[ $typenow ]; |
| 68 |
|
| 69 |
} elseif( isset( $bulk_messages['post'] ) ) { |
| 70 |
|
| 71 |
self::$bulk_post_updated_messages = $bulk_messages[ 'post' ]; |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
return $bulk_messages; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
public static function mywp_debug_renders( $debug_renders ) { |
| 80 |
|
| 81 |
if( ! is_admin() ) { |
| 82 |
|
| 83 |
return $debug_renders; |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
$debug_renders[ self::$id ] = array( |
| 88 |
'debug_type' => 'dev', |
| 89 |
'title' => __( 'Current Admin Information' , 'my-wp' ), |
| 90 |
); |
| 91 |
|
| 92 |
return $debug_renders; |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
protected static function get_debug_lists() { |
| 97 |
|
| 98 |
global $pagenow, $hook_suffix, $plugin_page, $page_hook, $typenow, $taxnow, $current_screen; |
| 99 |
global $post; |
| 100 |
global $user_id; |
| 101 |
|
| 102 |
$debug_lists = array( |
| 103 |
'$pagenow' => $pagenow, |
| 104 |
'$hook_suffix' => $hook_suffix, |
| 105 |
'$plugin_page' => $plugin_page, |
| 106 |
'$page_hook' => $page_hook, |
| 107 |
'$typenow' => $typenow, |
| 108 |
'$taxnow' => $taxnow, |
| 109 |
); |
| 110 |
|
| 111 |
if( in_array( $pagenow , array( 'post.php' , 'post-new.php' ) ) ) { |
| 112 |
|
| 113 |
$debug_lists['post_id'] = intval( $post->ID ); |
| 114 |
$debug_lists['post'] = $post; |
| 115 |
$debug_lists['custom_fields'] = get_post_meta( $post->ID ); |
| 116 |
|
| 117 |
$debug_lists['post_updated_messages'] = self::$post_updated_messages; |
| 118 |
|
| 119 |
} elseif( in_array( $pagenow , array( 'edit.php' ) ) ) { |
| 120 |
|
| 121 |
$debug_lists['post_type'] = $typenow; |
| 122 |
$debug_lists['counts'] = wp_count_posts( $typenow ); |
| 123 |
|
| 124 |
if( $typenow === 'page' ) { |
| 125 |
|
| 126 |
$debug_lists['column_filters'][] = 'manage_pages_columns'; |
| 127 |
|
| 128 |
} else { |
| 129 |
|
| 130 |
$debug_lists['column_filters'][] = 'manage_posts_columns'; |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
$debug_lists['column_filters'][] = sprintf( 'manage_%s_posts_columns (manage_{$typenow}_posts_columns)' , $typenow ); |
| 135 |
|
| 136 |
$debug_lists['sortable_column_filter'] = sprintf( 'manage_%s_sortable_columns (manage_{$this->screen->id}_sortable_columns)' , $current_screen->id ); |
| 137 |
|
| 138 |
if( $typenow === 'page' ) { |
| 139 |
|
| 140 |
$debug_lists['column_content_actions'][] = 'manage_pages_custom_column'; |
| 141 |
|
| 142 |
} else { |
| 143 |
|
| 144 |
$debug_lists['column_content_actions'][] = 'manage_posts_custom_column'; |
| 145 |
|
| 146 |
} |
| 147 |
|
| 148 |
$debug_lists['column_content_actions'][] = sprintf( 'manage_%s_posts_custom_column (manage_{$post->post_type}_posts_custom_column)' , $typenow ); |
| 149 |
|
| 150 |
$debug_lists['bulk_action_filter'] = sprintf( 'bulk_actions-%s (bulk_actions-{$this->screen->id})' , $current_screen->id ); |
| 151 |
|
| 152 |
$debug_lists['bulk_post_updated_messages'] = self::$bulk_post_updated_messages; |
| 153 |
|
| 154 |
} elseif( in_array( $pagenow , array( 'edit-tags.php' ) ) ) { |
| 155 |
|
| 156 |
$debug_lists['taxonomy'] = $taxnow; |
| 157 |
$debug_lists['count'] = wp_count_terms( $taxnow ); |
| 158 |
|
| 159 |
} elseif( in_array( $pagenow , array( 'term.php' ) ) ) { |
| 160 |
|
| 161 |
$debug_lists['taxonomy'] = $taxnow; |
| 162 |
$debug_lists['post_type'] = $typenow; |
| 163 |
|
| 164 |
$term_id = absint( $_REQUEST['tag_ID'] ); |
| 165 |
$deaub_lists['term_id'] = $term_id; |
| 166 |
$debug_lists['term'] = get_term( $term_id ); |
| 167 |
$debug_lists['custom_meta'] = get_term_meta( $term_id ); |
| 168 |
|
| 169 |
} elseif( in_array( $pagenow , array( 'users.php' ) ) ) { |
| 170 |
|
| 171 |
$debug_lists['count'] = count_users(); |
| 172 |
|
| 173 |
} elseif( in_array( $pagenow , array( 'user-edit.php' , 'profile.php' ) ) ) { |
| 174 |
|
| 175 |
$debug_lists['user_id'] = $user_id; |
| 176 |
$debug_lists['get_userdata()'] = get_userdata( $user_id ); |
| 177 |
$debug_lists['get_user_meta()'] = get_user_meta( $user_id ); |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
return $debug_lists; |
| 182 |
|
| 183 |
} |
| 184 |
|
| 185 |
protected static function mywp_developer_debug() { |
| 186 |
|
| 187 |
if( ! is_admin() ) { |
| 188 |
|
| 189 |
return false; |
| 190 |
|
| 191 |
} |
| 192 |
|
| 193 |
parent::mywp_developer_debug(); |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
protected static function mywp_debug_render() { |
| 198 |
|
| 199 |
if( ! is_admin() ) { |
| 200 |
|
| 201 |
return false; |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
parent::mywp_debug_render(); |
| 206 |
|
| 207 |
} |
| 208 |
|
| 209 |
} |
| 210 |
|
| 211 |
MywpDeveloperModuleDevAdmin::init(); |
| 212 |
|
| 213 |
endif; |
| 214 |
|