Wire social-share hook + make Follow button provider-aware
Release / Build & publish plugin zip (push) Successful in 7s

The social-share buttons function was hooked to
projects_after_download_button, but the template never fired that action —
the buttons never rendered. Added a do_action() call after the View Repo
button.

The Follow button hardcoded a GitHub URL and used the GitHub-specific
github-button class (which only acts on github.com). Replaced with a
plain styled link pointing at the owner's actual URL (works for any
provider). Removed the assets/js/buttons.js enqueue since nothing uses
the github-button class anymore.

Renamed the project-github-button CSS class on the View Repo link to
project-repo-button since it's provider-neutral now.
This commit is contained in:
Keith Solomon
2026-08-11 20:18:06 -05:00
parent 37832b72da
commit 5c843dc76f
2 changed files with 7 additions and 10 deletions
+4 -8
View File
@@ -115,7 +115,7 @@ function projects_portfolio_handle_download_redirect() {
// Use wp_redirect() (not wp_safe_redirect()) because the destination // Use wp_redirect() (not wp_safe_redirect()) because the destination
// is an external host the user has explicitly configured — wp_safe_redirect // is an external host the user has explicitly configured — wp_safe_redirect
// would reject it and fall back to admin_url(). // would reject it and fall back to admin_url().
wp_redirect( esc_url_raw( $download_url ), 302 ); wp_redirect( esc_url_raw( $download_url ), 302 ); // phpcs:ignore
exit; exit;
} else { } else {
wp_die( wp_die(
@@ -273,13 +273,9 @@ function projects_portfolio_enqueue_project_styles() {
} }
if ( is_singular( 'projects' ) ) { if ( is_singular( 'projects' ) ) {
wp_enqueue_script( // assets/js/buttons.js was used to render GitHub-style follow buttons.
'projects-wp-buttons', // The Follow button now uses a plain styled link (works for any provider),
plugin_dir_url( __FILE__ ) . 'assets/js/buttons.js', // so the script is no longer enqueued.
array(),
PROJECTS_PORTFOLIO_VERSION,
true
);
} }
} }
add_action( 'wp_enqueue_scripts', 'projects_portfolio_enqueue_project_styles' ); add_action( 'wp_enqueue_scripts', 'projects_portfolio_enqueue_project_styles' );
+3 -2
View File
@@ -69,12 +69,13 @@ if ( $last_updated ) {
<?php esc_html_e( 'Download Now', 'projects-wp' ); ?> <?php esc_html_e( 'Download Now', 'projects-wp' ); ?>
</a> </a>
<?php if ( $repo_url ) : ?> <?php if ( $repo_url ) : ?>
<a href="<?php echo esc_url( $browse_url ); ?>" class="button project-github-button" target="_blank" rel="noopener noreferrer"> <a href="<?php echo esc_url( $browse_url ); ?>" class="button project-repo-button" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'View Repo', 'projects-wp' ); ?> <?php esc_html_e( 'View Repo', 'projects-wp' ); ?>
</a> </a>
<?php else : ?> <?php else : ?>
<p><?php esc_html_e( 'Repository:', 'projects-wp' ); ?> <?php esc_html_e( 'No repository linked.', 'projects-wp' ); ?></p> <p><?php esc_html_e( 'Repository:', 'projects-wp' ); ?> <?php esc_html_e( 'No repository linked.', 'projects-wp' ); ?></p>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'projects_after_download_button', $project_id ); ?>
</div> </div>
<div class="project-meta"> <div class="project-meta">
@@ -151,7 +152,7 @@ if ( $last_updated ) {
</strong> </strong>
</span> </span>
<span> <span>
<a class="github-button" href="https://github.com/<?php esc_html_e( $owner_name ); ?>" data-show-count="true" data-color-scheme="no-preference: light; light: light; dark: dark;" data-size="large" aria-label="Follow @<?php esc_html_e( $owner_name ); ?> on GitHub"><?php esc_attr_e( 'Follow', 'projects-wp' ) ?></a> <a class="button project-follow-button" href="<?php echo esc_url( $owner_url ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Follow', 'projects-wp' ); ?></a>
</span> </span>
</div> </div>
<?php endif; ?> <?php endif; ?>