Может ли кто-нибудь показать мне, как включить этот файл javascript в мой плагин wordpress. Я перепробовал все методы wp_enqeue_script (), но ничего не вышло.
Хорошо, вот мой пример кода плагина с комментариями, объясняющими, что мне нужно.
<?php
/*
Plugin Name: Ava Test
Plugin URI: http://#.com
Description: A plugin that is used for my javascript tests
Author: Ronny Kibet
Author URI: http://ronnykibet.com
version: 1.001
*/
include(popup.js);
/*when I include it this way, it works fine, but gives an error when I activate the plugin
'plugin generated 453 characters ...'
*/
function popup() {
$src = plugins_url('popup.js', __FILE__);
wp_register_script( 'popup', $src );
wp_enqueue_script( 'popup' );
}
/*
when I included it this way, plugin is activated but nothing happens.
*/
?>
это popup.js
<script type="text/javascript">
function popup(){
alert('hello there this is a test popup')
}
</script>
<body onload="popup()">
</body>
Так кто-нибудь знает, как вызвать этот скрипт, чтобы он работал правильно в плагине wordpress?