You first example looks corrent. There is however a typo, hence class 'MyPluginAdmin' not found
.
You include myplugin-admin.php
, but then your question seems to suggest the page holding the class is in fact my-plugin-admin.php
(with a hypen).
If I correct the typo and run the code there are no warnings.
Edit (this works correctly):
my-plugin.php:
<?php
/*
Plugin Name: my-plugin.php
*/
include_once(plugin_dir_path(__FILE__) . '/my-plugin-admin.php');
register_activation_hook(__FILE__, array('MyPluginAdmin', 'activate'));
class MyPlugin {
}
my-plugin-admin.php:
<?php
/* my-plugin-admin.php */
class MyPluginAdmin {
public static function activate() {
}
}
With my-plugin.php
and my-plugin-admin.php
both in the same directory. Does my-plugin-admin.php
have the correct permissions?