Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filters to enable more customization #188

Merged
merged 4 commits into from
Jun 13, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,26 @@ public function admin_menu() {

foreach ( $this->plugins as $plugin ) {
if ( ! is_plugin_active( $plugin['file_path'] ) ) {
add_theme_page(
$this->strings['page_title'], // Page title.
$this->strings['menu_title'], // Menu title.
'edit_theme_options', // Capability.
$this->menu, // Menu slug.
array( $this, 'install_plugins_page' ) // Callback.
);
break;

$args = apply_filters(
'tgmpa_admin_menu_args',
array(
'parent_slug'=> 'themes.php', // Parent Menu slug.
'page_title' => $this->strings['page_title'], // Page title.
'menu_title' => $this->strings['menu_title'], // Menu title.
'capability' => 'edit_theme_options', // Capability.
'menu_slug' => $this->menu, // Menu slug.
'function' => array( $this, 'install_plugins_page' ) // Callback.
)
);

if( apply_filters( 'tgmpa_admin_menu_use_add_theme_page', true ) ) {
add_theme_page($args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function']);
} else {
add_submenu_page( $args['parent_slug'], $args['page_title'], $args['menu_title'], $args['capability'], $args['menu_slug'], $args['function']);
}

break;
}
}

Expand Down Expand Up @@ -616,7 +628,7 @@ public function notices() {

foreach ( $this->plugins as $plugin ) {
// If the plugin is installed and active, check for minimum version argument before moving forward.
if ( is_plugin_active( $plugin['file_path'] ) ) {
if ( is_plugin_active( $plugin['file_path'] ) || ( isset( $plugin['is_callable'] ) && is_callable( $plugin['is_callable'] ) ) ) {
// A minimum version has been specified.
if ( isset( $plugin['version'] ) ) {
if ( isset( $installed_plugins[$plugin['file_path']]['Version'] ) ) {
Expand Down Expand Up @@ -748,7 +760,7 @@ public function notices() {

$action_links = array_filter( $action_links ); // Remove any empty array items.
if ( $action_links ) {
$rendered .= '<p>' . implode( ' | ', $action_links ) . '</p>';
$rendered .= apply_filters( 'tgmpa_notice_rendered_action_links', '<p>' . implode( ' | ', $action_links ) . '</p>' );
}

// Register the nag messages and prepare them to be processed.
Expand Down Expand Up @@ -1133,7 +1145,7 @@ protected function _gather_plugin_data() {
$installed_plugins = get_plugins();

foreach ( TGM_Plugin_Activation::$instance->plugins as $plugin ) {
if ( is_plugin_active( $plugin['file_path'] ) ) {
if ( is_plugin_active( $plugin['file_path'] ) || ( isset( $plugin['is_callable'] ) && is_callable( $plugin['is_callable'] ) ) ) {
continue; // No need to display plugins if they are installed and activated.
}

Expand Down Expand Up @@ -1193,6 +1205,8 @@ protected function _gather_plugin_data() {
$table_data[$i]['file_path'] = $plugin['file_path'];
$table_data[$i]['url'] = isset( $plugin['source'] ) ? $plugin['source'] : 'repo';

$table_data[$i] = apply_filters( 'tgmpa_table_data_item', $table_data[$i], $plugin );

$i++;
}

Expand Down Expand Up @@ -1380,7 +1394,7 @@ public function get_columns() {
'status' => __( 'Status', 'tgmpa' )
);

return $columns;
return apply_filters( 'tgmpa_table_columns', $columns );

}

Expand Down