Created
October 9, 2015 07:41
-
-
Save manishsongirkar/de55c8a3f035e2cfcded to your computer and use it in GitHub Desktop.
Custom Post Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Rename Aside post format to Look post format | |
*/ | |
function rtp_rename_post_formats( $safe_text ) { | |
if ( $safe_text == __( 'Aside' , 'fab' ) ) { | |
return __( 'Look' , 'fab' ); | |
} | |
return $safe_text; | |
} | |
add_filter( 'esc_html', 'rtp_rename_post_formats' ); | |
/** | |
* Rename Aside in posts list table | |
*/ | |
function rtp_live_rename_formats() { | |
global $current_screen; | |
if ( $current_screen->id == 'edit-post' ) { ?> | |
<script type="text/javascript"> | |
jQuery( 'document' ).ready(function() { | |
jQuery( 'span.post-state-format' ).each( function() { | |
if ( jQuery(this).text() == <?php _e( 'Aside' , 'fab' ); ?> ) | |
jQuery(this).text( <?php _e( 'Look' , 'fab' ); ?> ); | |
} ); | |
} ); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'admin_head', 'rtp_live_rename_formats' ); | |
/** | |
* Adds custom classes to the array of body classes. | |
* | |
* @param array $classes Classes for the body element. | |
* @return array | |
*/ | |
function fab_look_body_classes( $classes ) { | |
foreach ( $classes as $key => $value ) { | |
if ( $value == 'single-format-aside' ) { | |
unset( $classes[ $key ] ); | |
$classes[] = 'single-format-look'; | |
} | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'fab_look_body_classes' ); | |
/** | |
* Update aside class to look class of post classes. | |
* | |
* @param array $classes Classes for the post element. | |
* @return array | |
*/ | |
function fab_post_classes( $classes ) { | |
foreach ( $classes as $key => $value ) { | |
if ( $value == 'format-aside' ) { | |
unset( $classes[ $key ] ); | |
$classes[] = 'format-look'; | |
} | |
if ( $value == 'post_format-post-format-aside' ) { | |
unset( $classes[ $key ] ); | |
$classes[] = 'post_format-post-format-look'; | |
} | |
} | |
return $classes; | |
} | |
add_filter( 'post_class', 'fab_post_classes' ); | |
/** | |
* Remove post format support for post type post | |
*/ | |
function rtp_remove_support() { | |
remove_post_type_support( 'post', 'post-formats' ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment