Last active
March 13, 2018 22:32
-
-
Save radist2s/9b5f78a750fc93ce659f0d186a6c8886 to your computer and use it in GitHub Desktop.
GitHub Updater plugins header override
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
<? | |
define('GITHUB_UPDATER_OVERRIDE_DOT_ORG', TRUE); | |
function get_plugins_overrides() | |
{ | |
static $map = NULL; | |
if ($map !== NULL) | |
{ | |
return $map; | |
} | |
// Use 'github_updater_additions' filter to find plugin | |
return $map = [ | |
'plugin-dir/plugin-file.php' => [ | |
'after_plugin_row_remove' => TRUE, | |
'github_repository' => 'https://github.com/author/repo' | |
] | |
]; | |
} | |
add_filter('github_updater_additions', function ($null, $plugins) | |
{ | |
if (!$plugins) | |
{ | |
return $null; | |
} | |
$plugins_update_map = get_plugins_overrides(); | |
$updating_plugins = []; | |
foreach ($plugins as $plugin_file => $plugin_data) | |
{ | |
if (empty($plugins_update_map[$plugin_file]) OR empty($plugins_update_map[$plugin_file]['github_repository'])) | |
{ | |
continue; | |
} | |
$updating_plugins[$plugin_file] = $plugin_data; | |
$updating_plugins[$plugin_file]['GitHub Plugin URI'] = $plugins_update_map[$plugin_file]['github_repository']; | |
} | |
return $updating_plugins; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment