コード例 #1
0
ファイル: gitium.php プロジェクト: leshuis/testwp
function gitium_upgrader_post_install($res, $hook_extra, $result)
{
    _gitium_make_ssh_git_file_exe();
    $type = isset($hook_extra['theme']) ? 'theme' : 'plugin';
    $action = isset($hook_extra['action']) ? $hook_extra['action'] : 'updated';
    $action = 'install' === $action ? 'installed' : $action;
    $git_dir = $result['destination'];
    $version = '';
    if (ABSPATH == substr($git_dir, 0, strlen(ABSPATH))) {
        $git_dir = substr($git_dir, strlen(ABSPATH));
    }
    switch ($type) {
        case 'theme':
            wp_clean_themes_cache();
            $theme_data = wp_get_theme($result['destination_name']);
            $name = $theme_data->get('Name');
            $version = $theme_data->get('Version');
            break;
        case 'plugin':
            foreach ($result['source_files'] as $file) {
                if ('.php' != substr($file, -4)) {
                    continue;
                }
                // every .php file is a possible plugin so we check if it's a plugin
                $filepath = trailingslashit($result['destination']) . $file;
                $plugin_data = get_plugin_data($filepath);
                if ($plugin_data['Name']) {
                    $name = $plugin_data['Name'];
                    $version = $plugin_data['Version'];
                    // We get info from the first plugin in the package
                    break;
                }
            }
            break;
    }
    if (empty($name)) {
        $name = $result['destination_name'];
    }
    $commit_message = _gitium_format_message($name, $version, "{$action} {$type}");
    $commit = _gitium_commit_changes($commit_message, $git_dir, false);
    gitium_merge_and_push($commit);
    return $res;
}
コード例 #2
0
ファイル: functions.php プロジェクト: leshuis/testwp
function gitium_check_after_event($plugin, $event = 'activation')
{
    global $git;
    if ('gitium/gitium.php' == $plugin) {
        return;
    }
    // do not hook on activation of this plugin
    if ($git->is_dirty()) {
        $versions = gitium_update_versions();
        if (isset($versions['plugins'][$plugin])) {
            $name = $versions['plugins'][$plugin]['name'];
            $version = $versions['plugins'][$plugin]['version'];
        } else {
            $name = $plugin;
        }
        gitium_auto_push(_gitium_format_message($name, $version, "after {$event} of"));
    }
}