Sorry for the very late here.
Just imagine that you want to change the description of one of the modules. Let’s say, for instance, that we are going to change Carousel description module.
Currently, this is the description of Carousel included in module-info.php:
function jetpack_carousel_more_info() {
?>
<div class="jp-info-img">
<img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/_inc/images/screenshots/carousel.png' ) ?>" alt="<?php esc_attr_e( 'Gallery Carousel Screenshot', 'jetpack' ) ?>" width="300" height="188" />
</div>
<p><?php esc_html_e( 'With Carousel active, any standard WordPress galleries you have embedded in posts or pages will launch a gorgeous full-screen photo browsing experience with comments and EXIF metadata.', 'jetpack' ); ?></p>
<?php
}
add_action( 'jetpack_learn_more_button_carousel', 'jetpack_carousel_learn_more_button' );
add_action( 'jetpack_module_more_info_carousel', 'jetpack_carousel_more_info' );
So , the idea is to remove those actions and put my own ones, I use a mu-plugin for that:
remove_action( 'jetpack_learn_more_button_carousel', 'jetpack_carousel_learn_more_button' );
remove_action( 'jetpack_module_more_info_carousel', 'jetpack_carousel_more_info' );
But that did, ehm, nothing. The information is still there. But that’s logicall, when I remove those filters, modules-info.php is still not loaded.
Let’s search then for a hook that is fired right after the file is included so I can remove those hooks. The file is included in class.jetpack-admin.php among other two files. Let’s see the code:
function get_modules() {
include_once( JETPACK__PLUGIN_DIR . 'modules/module-info.php' );
$available_modules = $this->jetpack->get_available_modules();
$active_modules = $this->jetpack->get_active_modules();
$modules = array();
foreach ( $available_modules as $module ) {
...
// Save the modules info in an array
...
}
Well, there’s not a hook there so the hooks included in modules-info.php are a little useless.
There are several options to fix this and one of them would be to add a new action at the end of the module-info.php file:
do_action( 'jetpack_module_info_loaded' );
Or similar, of course. That hook will allow me to remove the actions that module-info.php added:
add_action( 'jetpack_module_info_loaded', 'jetpack_hooks_remove_current_module_info_actions' );
function jetpack_hooks_remove_current_module_info_actions() {
remove_action( 'jetpack_learn_more_button_carousel', 'jetpack_carousel_learn_more_button' );
remove_action( 'jetpack_module_more_info_carousel', 'jetpack_carousel_more_info' );
}
I don’t know if is clear enough π
Thanks.