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; }
function gitium_group_commit_modified_plugins_and_themes($msg_append = '') { global $git; $uncommited_changes = $git->get_local_changes(); $commit_groups = array(); $commits = array(); if (!empty($msg_append)) { $msg_append = "({$msg_append})"; } foreach ($uncommited_changes as $path => $action) { $change = _gitium_module_by_path($path); $change['action'] = $action; $commit_groups[$change['base_path']] = $change; } foreach ($commit_groups as $base_path => $change) { $commit_message = _gitium_format_message($change['name'], $change['version'], "{$change['action']} {$change['type']}"); $commit = _gitium_commit_changes("{$commit_message} {$msg_append}", $base_path, false); if ($commit) { $commits[] = $commit; } } return $commits; }