Created
March 6, 2017 10:34
-
-
Save hsleonis/b0a8cf8741776c6f592a8643b0a8e8d2 to your computer and use it in GitHub Desktop.
Add custom fields in attachment page
This file contains hidden or 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 | |
add_action( 'attachment_fields_to_edit', array($this, 'tmx_attachment_fields_to_edit'), 10, 2 ); | |
public function tmx_attachment_fields_to_edit( $form_fields, $post ){ | |
// Apply only in image attachment pages | |
if( $post->post_mime_type == 'image/jpeg' || $post->post_mime_type == 'image/jpg' || $post->post_mime_type == 'image/png' ){ | |
$form_fields['tmx-apply-filter-sbutton'] = array( | |
'label' => __('Add Image effects', 'themeaxe'), | |
'input' => 'html', | |
'helps' => __('Apply filter effects to image.', 'themeaxe'), | |
'html' => '<a class="button easy-image-filters-button" href="'.admin_url('upload.php?page=easy-image-filters-page').'&attachment_id='.$post->ID.'">'.__('Add','themeaxe').'</a>', | |
); | |
} | |
return $form_fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment