Last active
July 12, 2017 15:23
-
-
Save campusboy87/e2935b7117d0c7e59662bbce1481e930 to your computer and use it in GitHub Desktop.
Автоматическое добавление названия изображения при выборе фотки в поле названия поста. Можно указать тип поста.
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
// Автодобавление названия изображения при выборе фотки в поле названия поста | |
add_action( 'admin_print_footer_scripts', function () { | |
global $current_screen; | |
if ( 'post' == $current_screen->post_type && 'post' == $current_screen->base ) { | |
?> | |
<script> | |
jQuery(document).ready(function ($) { | |
var $titlePostInput = $('[name=post_title]'); | |
$(document).on('mouseenter', '.media-button-select', function () { | |
var titlePostText = $titlePostInput.val(); | |
var titleImg = $('[data-setting=title] input').val(); | |
if (!titlePostText && titleImg) { | |
$titlePostInput.val(titleImg).focus(); | |
} | |
}); | |
}); | |
</script> | |
<?php | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment