Skip to content
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion assets-src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const promoteImagifyButton = createHigherOrderComponent( ( BlockEdit ) => {
initialOpen={true}
>
<p style={{marginLeft: 16}}>
{__('Boost your site’s performance by compressing images with Imagify, developed by WP Rocket.', '%domain%')}
{ wpmedia_pluginfamily.notice_text }
</p>
{success ? (
<a
Expand Down
29 changes: 25 additions & 4 deletions src/Controller/PluginFamily.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,9 @@ public function install_imagify() {
wp_send_json_error( $activated->get_error_message() );
}

$this->set_imagify_partner( '%imagifypartnerid%' );
// Allow host plugin to define the Imagify partner ID.
$partner = apply_filters( 'wpmedia/plugin_family/imagify_partner', '%imagifypartnerid%' );
$this->set_imagify_partner( $partner );
Comment on lines +390 to +392
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already cater for dynamic partner ID, you only need to add imagify_partner to your extra option in composer.json. During installation of the package, composer will take care of this and automatically pick the ID from your composer.json and replace the wildcard with it. you should also configure your plugin_domain as well
Screenshot 2025-09-01 at 08 50 59

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jeawhanlee

I'll make this change in the plugin. Still we'll need to add some hook when plugin is being installed because we also want to add tracking event.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jeawhanlee

I added imagify_partner in composer.json file, but that is not working on my setup. Upon installing the plugin, the %imagifypartnerid% is stored in the imagifyp_id . Here is the composer.json file from my setup:
composer.json

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that to work, you'll need to use a post-install-cmd and post-update-cmd, majorly to perform the same operations for both composer install & update. We do that here for WPR

wp_send_json_success( __( 'Imagify installed! Click here to start using it.', '%domain%' ) );
}

Expand All @@ -411,10 +413,28 @@ private function can_enqueue_admin_assets( $page = '' ): bool {
if ( $this->is_promote_imagify_dismissed() ) {
return false;
}
if ( empty( $page ) ) {
return in_array( get_current_screen()->id, [ 'post', 'upload' ], true );

// Allow core admin screens; third-parties can extend via the filter below.
$allowed_pages = [ 'post.php', 'post-new.php', 'upload.php' ];

// If hook suffix is provided by admin_enqueue_scripts.
if ( ! empty( $page ) ) {
$allowed = in_array( $page, $allowed_pages, true );
/**
* Filter whether plugin-family assets can be enqueued on a given admin page.
*
* @param bool $allowed Whether enqueuing is allowed.
* @param string $page Hook suffix.
* @param string $screen Screen ID (empty in this branch).
*/
return (bool) apply_filters( 'wpmedia/plugin_family/can_enqueue_admin_assets', $allowed, $page, '' );
}
return in_array( $page, [ 'post.php', 'post-new.php', 'upload.php' ], true );

// Fallback to current screen ID checks.
$screen_id = function_exists( 'get_current_screen' ) && get_current_screen() ? get_current_screen()->id : '';
$allowed = in_array( $screen_id, [ 'post', 'upload' ], true ) || in_array( $screen_id, $allowed_pages, true );

return (bool) apply_filters( 'wpmedia/plugin_family/can_enqueue_admin_assets', $allowed, '', $screen_id );
}

/**
Expand All @@ -428,6 +448,7 @@ private function add_install_imagify_localized_script( $script_id ) {
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'install-imagify-nonce' ),
'plugins_page_url' => admin_url( 'plugins.php' ),
'notice_text' => apply_filters( 'wpmedia/plugin_family/notice_text', esc_html__( 'Boost your site\'s performance by compressing images with Imagify, developed by WP Rocket.', '%domain%' ) ),
Comment thread
jeawhanlee marked this conversation as resolved.
];
wp_add_inline_script(
$script_id,
Expand Down
15 changes: 9 additions & 6 deletions src/View/promote-imagify-uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
</button>
<p>
<?php
printf(
// translators: %1$is = Plugin Name.
esc_html__( '%1$s recommends you to optimize your images for even better website performance.', '%domain%' ),
'WP Rocket'
);
echo apply_filters(
'wpmedia/plugin_family/notice_text',
sprintf(
// translators: %1$is = Plugin Name.
esc_html__( '%1$s recommends you to optimize your images for even better website performance.', '%domain%' ),
'WP Rocket'
)
);
Comment thread
jeawhanlee marked this conversation as resolved.
?>
</p>
<button id="pluginfamily_install_imagify"><?php esc_html_e( 'Install Imagify Plugin', '%domain%' ); ?></button>
</div>
</script>
</script>
2 changes: 1 addition & 1 deletion src/assets/js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading