array(
'title' => __( 'Post updated' , 'mywp' ),
'message' => __( 'Post updated.' ),
),
2 => array(
'title' => __( 'Custom field updated' , 'mywp' ),
'message' => __( 'Custom field updated.' ),
),
3 => array(
'title' => __( 'Custom field deleted' , 'mywp' ),
'message' => __( 'Custom field updated.' ),
),
4 => array(
'title' => __( 'Post updated' , 'mywp' ),
'message' => __( 'Post updated.' ),
),
5 => array(
'title' => __( 'Revision' ),
'message' => sprintf( __( 'Post restored to revision from %s.' ), __( 'Post Title' ) ),
),
6 => array(
'title' => __( 'Post published' , 'mywp' ),
'message' => __( 'Post published.' ),
),
7 => array(
'title' => __( 'Post saved' , 'mywp' ),
'message' => __( 'Post saved.' ),
),
8 => array(
'title' => __( 'Post submitted' , 'mywp' ),
'message' => __( 'Post submitted.' ),
),
9 => array(
'title' => __( 'Post Scheduled' , 'mywp' ),
'message' => sprintf( __( 'Post scheduled for: %s.' ), '' . __( 'Schedule Date' , 'mywp' ) . '' ) . __( 'Schedule Link' , 'mywp' ),
),
10 => array(
'title' => __( 'Post draft updated' , 'mywp' ),
'message' => __( 'Post draft updated.' ) . __( 'Preview Post Link' ),
),
);
return $update_messages_default;
}
public static function mywp_wp_loaded() {
if( ! is_admin() ) {
return false;
}
if( is_network_admin() ) {
return false;
}
if( ! self::is_do_controller() ) {
return false;
}
add_action( 'load-post.php' , array( __CLASS__ , 'load_post' ) , 1000 );
add_action( 'load-post-new.php' , array( __CLASS__ , 'load_post' ) , 1000 );
}
public static function mywp_get_option_key( $option_key ) {
if( empty( self::$post_type ) ) {
return $option_key;
}
$option_key .= '_' . self::$post_type;
return $option_key;
}
public static function load_post() {
global $typenow;
if( empty( $typenow ) ) {
return false;
}
self::$post_type = $typenow;
add_filter( 'mywp_get_option_key_mywp_admin_post_edit' , array( __CLASS__ , 'mywp_get_option_key' ) );
add_filter( 'post_updated_messages' , array( __CLASS__ , 'change_post_updated_messages' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_add_new' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_title' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_permalink' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_change_permalink' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_content' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_publish_metabox_draft' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_publish_metabox_preview' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_publish_metabox_change_post_status' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_publish_metabox_change_publish_status' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_publish_metabox_change_publish_on' ) );
add_action( 'admin_print_styles' , array( __CLASS__ , 'forced_editor_buttons' ) );
add_action( 'admin_head' , array( __CLASS__ , 'hide_meta_boxes' ) );
add_action( 'in_admin_header' , array( __CLASS__ , 'remove_meta_boxes' ) );
add_action( 'in_admin_header' , array( __CLASS__ , 'change_title_meta_boxes' ) );
add_filter( 'wp_default_editor' , array( __CLASS__ , 'forced_editor' ) );
add_filter( 'enter_title_here' , array( __CLASS__ , 'change_title_placeholder' ) );
add_action( 'admin_print_footer_scripts' , array( __CLASS__ , 'prevent_meta_boxes' ) );
add_action( 'admin_print_footer_scripts' , array( __CLASS__ , 'auto_create_title' ) );
}
public static function change_post_updated_messages( $post_updated_messages ) {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return $post_updated_messages;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['post_updated_messages'] ) ) {
return $post_updated_messages;
}
$post_updated_messages_default = self::get_update_messages_default();
foreach( $post_updated_messages_default as $key => $v ) {
if( ! empty( $setting_data['post_updated_messages'][ $key ] ) ) {
$post_updated_messages[ self::$post_type ][ $key ] = $setting_data['post_updated_messages'][ $key ];
}
}
self::after_do_function( __FUNCTION__ );
return $post_updated_messages;
}
public static function hide_add_new() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_add_new'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_title() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_title'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_permalink() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_permalink'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_change_permalink() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_change_permalink'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_content() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_content'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_publish_metabox_draft() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_publish_metabox_draft'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_publish_metabox_preview() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_publish_metabox_preview'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_publish_metabox_change_post_status() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_publish_metabox_change_post_status'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_publish_metabox_change_publish_status() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_publish_metabox_change_publish_status'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_publish_metabox_change_publish_on() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['hide_publish_metabox_change_publish_on'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function forced_editor_buttons() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['forced_editor'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function hide_meta_boxes() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['meta_boxes'] ) ) {
return false;
}
$hide_meta_boxes = array();
foreach( $setting_data['meta_boxes'] as $meta_box_id => $meta_box_setting ) {
if( $meta_box_setting['action'] != 'hide' ) {
continue;
}
$hide_meta_boxes[] = $meta_box_id;
}
if( empty( $hide_meta_boxes ) ) {
return false;
}
echo '';
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function remove_meta_boxes() {
global $wp_meta_boxes;
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['meta_boxes'] ) ) {
return false;
}
$remove_meta_boxes = array();
foreach( $setting_data['meta_boxes'] as $meta_box_id => $meta_box_setting ) {
if( $meta_box_setting['action'] != 'remove' ) {
continue;
}
$remove_meta_boxes[] = $meta_box_id;
}
if( empty( $remove_meta_boxes ) ) {
return false;
}
if( empty( $wp_meta_boxes[ self::$post_type ] ) ) {
return false;
}
$current_meta_boxes = $wp_meta_boxes[ self::$post_type ];
foreach( $current_meta_boxes as $context => $priority_meta_boxes ) {
if( empty( $priority_meta_boxes ) or ! is_array( $priority_meta_boxes ) ) {
continue;
}
foreach( $priority_meta_boxes as $priority => $meta_boxes ) {
if( empty( $meta_boxes ) or ! is_array( $meta_boxes ) ) {
continue;
}
foreach( $meta_boxes as $meta_box_id => $meta_box ) {
if( empty( $meta_box ) or ! is_array( $meta_box ) ) {
continue;
}
if( ! in_array( $meta_box_id , $remove_meta_boxes ) ) {
continue;
}
remove_meta_box( $meta_box_id , self::$post_type , $context );
}
}
}
self::after_do_function( __FUNCTION__ );
}
public static function change_title_meta_boxes() {
global $wp_meta_boxes;
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['meta_boxes'] ) ) {
return false;
}
$change_title_meta_boxes = array();
foreach( $setting_data['meta_boxes'] as $meta_box_id => $meta_box_setting ) {
if( ! empty( $meta_box_setting['action'] ) ) {
continue;
}
if( empty( $meta_box_setting['title'] ) ) {
continue;
}
$change_title_meta_boxes[ $meta_box_id ] = $meta_box_setting['title'];
}
if( empty( $change_title_meta_boxes ) ) {
return false;
}
if( empty( $wp_meta_boxes[ self::$post_type ] ) ) {
return false;
}
$current_meta_boxes = $wp_meta_boxes[ self::$post_type ];
foreach( $current_meta_boxes as $context => $priority_meta_boxes ) {
if( empty( $priority_meta_boxes ) or ! is_array( $priority_meta_boxes ) ) {
continue;
}
foreach( $priority_meta_boxes as $priority => $meta_boxes ) {
if( empty( $meta_boxes ) or ! is_array( $meta_boxes ) ) {
continue;
}
foreach( $meta_boxes as $meta_box_id => $meta_box ) {
if( empty( $meta_box ) or ! is_array( $meta_box ) ) {
continue;
}
if( empty( $change_title_meta_boxes[ $meta_box_id ] ) ) {
continue;
}
$wp_meta_boxes[ self::$post_type ][ $context ][ $priority ][ $meta_box_id ]['title'] = do_shortcode( $change_title_meta_boxes[ $meta_box_id ] );
}
}
}
self::after_do_function( __FUNCTION__ );
}
public static function forced_editor( $wp_default_editor ) {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return $wp_default_editor;
}
$setting_data = self::get_setting_data();
if( ! empty( $setting_data['forced_editor'] ) or in_array( $setting_data['forced_editor'] , array( 'text' , 'tinymce' ) ) ) {
$wp_default_editor = $setting_data['forced_editor'];
}
self::after_do_function( __FUNCTION__ );
return $wp_default_editor;
}
public static function change_title_placeholder( $title_placeholder ) {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return $title_placeholder;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['change_title_placeholder'] ) ) {
return $title_placeholder;
}
$title_placeholder = $setting_data['change_title_placeholder'];
self::after_do_function( __FUNCTION__ );
return $title_placeholder;
}
public static function prevent_meta_boxes() {
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['prevent_meta_box'] ) ) {
return false;
}
echo '';
echo '';
self::after_do_function( __FUNCTION__ );
}
public static function auto_create_title() {
global $post;
if( empty( $post ) or empty( $post->ID ) ) {
return false;
}
if( ! self::is_do_function( __FUNCTION__ ) ) {
return false;
}
$setting_data = self::get_setting_data();
if( empty( $setting_data['auto_create_title'] ) ) {
return false;
}
echo '';
self::after_do_function( __FUNCTION__ );
}
}
MywpControllerModuleAdminPostEdit::init();
endif;