| 1 |
<?php |
| 2 |
/* Adds Catch Plugins tab in Add Plugin page to show all plugins by Catch Plugins in wordpress.org */ |
| 3 |
if( ! function_exists( 'add_our_plugins_tab' ) ) { |
| 4 |
function add_our_plugins_tab($tabs) { |
| 5 |
// Add our filter here |
| 6 |
$tabs['catchplugins'] = _x( 'Catch Plugins', 'Plugin Installer' ); |
| 7 |
|
| 8 |
return $tabs; |
| 9 |
} |
| 10 |
add_filter( 'install_plugins_tabs', 'add_our_plugins_tab', 1 ); |
| 11 |
} |
| 12 |
|
| 13 |
if( ! function_exists( 'catchplugins' ) ) { |
| 14 |
function catchplugins() { |
| 15 |
/* From CORE Start */ |
| 16 |
global $paged, $tab; |
| 17 |
wp_reset_vars( array( 'tab' ) ); |
| 18 |
|
| 19 |
$defined_class = new WP_Plugin_Install_List_Table(); |
| 20 |
$paged = $defined_class->get_pagenum(); |
| 21 |
|
| 22 |
$per_page = 30; |
| 23 |
//$installed_plugins = catch_get_installed_plugins(); |
| 24 |
|
| 25 |
$args = array( |
| 26 |
'page' => $paged, |
| 27 |
'per_page' => $per_page, |
| 28 |
'fields' => array( |
| 29 |
'last_updated' => true, |
| 30 |
'icons' => true, |
| 31 |
'active_installs' => true |
| 32 |
), |
| 33 |
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results. |
| 34 |
'locale' => get_user_locale(), |
| 35 |
//'installed_plugins' => array_keys( $installed_plugins ), |
| 36 |
); |
| 37 |
/* From CORE End */ |
| 38 |
|
| 39 |
// Add author filter for our plugins |
| 40 |
$args['author'] = 'catchplugins'; |
| 41 |
|
| 42 |
return $args; |
| 43 |
} |
| 44 |
add_filter( "install_plugins_table_api_args_catchplugins", 'catchplugins', 1 ); |
| 45 |
} |
| 46 |
|
| 47 |
if( ! function_exists( 'cathcplugins_plugins_table' ) ) { |
| 48 |
add_action( 'install_plugins_catchplugins', 'cathcplugins_plugins_table' ); |
| 49 |
function cathcplugins_plugins_table() { |
| 50 |
global $wp_list_table; |
| 51 |
printf( |
| 52 |
'<p class="catch-plugins-list">' . __( 'You can use any of our free plugins or premium plugins from <a href="%s" target="_blank">Catch Plugins</a>' ) . '.</p>', |
| 53 |
'https://catchplugins.com/' |
| 54 |
); |
| 55 |
?> |
| 56 |
<form id="plugin-filter" method="post"> |
| 57 |
<?php $wp_list_table->display(); ?> |
| 58 |
</form> |
| 59 |
<?php |
| 60 |
} |
| 61 |
} |