| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
// Fetch plugin information from WordPress.org |
| 7 |
if ( ! function_exists( 'plugins_api' ) ) { |
| 8 |
require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 9 |
} |
| 10 |
|
| 11 |
$author_slug = 'awordpresslife'; |
| 12 |
$transient_key = 'ag_our_plugins_data'; |
| 13 |
|
| 14 |
// Force refresh the data to apply new categorization rules |
| 15 |
if ( isset($_GET['refresh_plugins']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'ag_refresh_plugins') ) { |
| 16 |
delete_transient( $transient_key ); |
| 17 |
} |
| 18 |
|
| 19 |
$plugins = get_transient( $transient_key ); |
| 20 |
|
| 21 |
if ( false === $plugins ) { |
| 22 |
$api_args = array( |
| 23 |
'author' => $author_slug, |
| 24 |
'per_page' => 100, // Fetch all plugins |
| 25 |
'fields' => array( |
| 26 |
'icons' => true, |
| 27 |
'banners' => true, |
| 28 |
'active_installs' => true, |
| 29 |
'short_description' => true, |
| 30 |
'rating' => true, |
| 31 |
'num_ratings' => true, |
| 32 |
'last_updated' => true, |
| 33 |
), |
| 34 |
); |
| 35 |
|
| 36 |
$response = plugins_api( 'query_plugins', $api_args ); |
| 37 |
|
| 38 |
if ( ! is_wp_error( $response ) && isset( $response->plugins ) ) { |
| 39 |
$plugins = $response->plugins; |
| 40 |
// Cache for 12 hours |
| 41 |
set_transient( $transient_key, $plugins, 12 * HOUR_IN_SECONDS ); |
| 42 |
} else { |
| 43 |
$plugins = array(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
// Filter and Categorize |
| 48 |
$filtered_plugins = array(); |
| 49 |
|
| 50 |
// Define the desired manual position of plugins by slug |
| 51 |
$manual_slug_order = array( |
| 52 |
'frank-website-seo-checker-and-audit', |
| 53 |
'frank-responsive-checker', |
| 54 |
'frank-dead-link-checker', |
| 55 |
'right-click-disable-or-ban', |
| 56 |
'frank-schema-markup-generator', |
| 57 |
'ultimate-portfolio', |
| 58 |
'hash-converter', |
| 59 |
'lead-generation-form', |
| 60 |
'online-job-board', |
| 61 |
'new-grid-gallery', |
| 62 |
'new-photo-gallery', |
| 63 |
'new-image-gallery', |
| 64 |
'portfolio-filter-gallery', |
| 65 |
'event-monster' |
| 66 |
); |
| 67 |
|
| 68 |
// List of keywords or slugs for "New Releases" |
| 69 |
$new_keywords = array( |
| 70 |
'Website SEO Checker', |
| 71 |
'Responsive Checker', |
| 72 |
'Dead Link Checker', |
| 73 |
'Schema Markup Generator', |
| 74 |
'Right Click Ban', |
| 75 |
'Ultimate Portfolio', |
| 76 |
'Universal Unit Converter', |
| 77 |
'Job Board', |
| 78 |
'Lead Generation Form' |
| 79 |
); |
| 80 |
|
| 81 |
// Fallback Slugs |
| 82 |
$new_slugs = array( |
| 83 |
'frank-website-seo-checker-and-audit', |
| 84 |
'frank-responsive-checker', |
| 85 |
'dead-link-checker', |
| 86 |
'schema-markup-generator', |
| 87 |
'right-click-ban', |
| 88 |
'ultimate-portfolio', |
| 89 |
'universal-unit-converter', |
| 90 |
'lead-generation-form', |
| 91 |
'job-board-manager' |
| 92 |
); |
| 93 |
|
| 94 |
$technical_slugs = array( |
| 95 |
'wp-life-companion', |
| 96 |
'shortcode-generator', |
| 97 |
'dead-link-checker', |
| 98 |
'schema-markup-generator', |
| 99 |
'right-click-ban', |
| 100 |
'frank-responsive-checker', |
| 101 |
'frank-website-seo-checker-and-audit' |
| 102 |
); |
| 103 |
|
| 104 |
// Technical Keywords |
| 105 |
$technical_keywords = array( |
| 106 |
'Website SEO Checker', |
| 107 |
'Right Click Ban', |
| 108 |
'Dead Link Checker', |
| 109 |
'Schema Markup Generator', |
| 110 |
'Shortcode Generator', |
| 111 |
'Login Page Customizer', |
| 112 |
'Responsive Checker', |
| 113 |
); |
| 114 |
|
| 115 |
// Social Media Keywords |
| 116 |
$social_keywords = array( 'social', 'share', 'facebook', 'instagram', 'twitter', 'tiktok', 'feed', 'icon', 'whatsapp', 'messenger', 'flickr', 'youtube', 'vimeo' ); |
| 117 |
|
| 118 |
// Marketing & Growth Keywords |
| 119 |
$marketing_keywords = array( 'Event Monster', 'Testimonial', 'Pricing Table', 'Team Member', 'Coming Soon', 'Maintenance', 'Contact Form', 'Lead Generation' ); |
| 120 |
|
| 121 |
// Social Media Manual Names |
| 122 |
$social_manual_names = array( |
| 123 |
'Animated Live Wall', |
| 124 |
'Album Gallery For Flickr', |
| 125 |
'Album Photostream Flickr Gallery', |
| 126 |
'Video Gallery YouTube Vimeo' |
| 127 |
); |
| 128 |
|
| 129 |
foreach ( $plugins as $plugin ) { |
| 130 |
$plugin = (array) $plugin; |
| 131 |
$slug = isset($plugin['slug']) ? $plugin['slug'] : ''; |
| 132 |
$name = isset($plugin['name']) ? $plugin['name'] : ''; |
| 133 |
|
| 134 |
// 1. Remove Companion plugins |
| 135 |
if ( stripos( $slug, 'companion' ) !== false ) { |
| 136 |
continue; |
| 137 |
} |
| 138 |
|
| 139 |
// 2. Assign Categories |
| 140 |
$categories = array( 'all' ); |
| 141 |
|
| 142 |
// Popular if > 5,000 installs |
| 143 |
if ( isset($plugin['active_installs']) && (int) $plugin['active_installs'] >= 5000 ) { |
| 144 |
$categories[] = 'popular'; |
| 145 |
} |
| 146 |
|
| 147 |
// New if slug matches or name contains keywords |
| 148 |
$is_new = false; |
| 149 |
if ( in_array( $slug, $new_slugs ) ) { |
| 150 |
$is_new = true; |
| 151 |
} else { |
| 152 |
foreach ( $new_keywords as $keyword ) { |
| 153 |
if ( stripos( $name, $keyword ) !== false ) { |
| 154 |
$is_new = true; |
| 155 |
break; |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
if ( $is_new ) { |
| 160 |
$categories[] = 'new'; |
| 161 |
} |
| 162 |
|
| 163 |
// Technical check |
| 164 |
$is_technical = false; |
| 165 |
if ( in_array( $slug, $technical_slugs ) ) { |
| 166 |
$is_technical = true; |
| 167 |
} else { |
| 168 |
foreach ( $technical_keywords as $t_keyword ) { |
| 169 |
if ( stripos( $name, $t_keyword ) !== false ) { |
| 170 |
$is_technical = true; |
| 171 |
break; |
| 172 |
} |
| 173 |
} |
| 174 |
} |
| 175 |
if ( $is_technical ) { |
| 176 |
$categories[] = 'technical'; |
| 177 |
} |
| 178 |
|
| 179 |
// Marketing & Growth check |
| 180 |
foreach ( $marketing_keywords as $m_keyword ) { |
| 181 |
if ( stripos( $name, $m_keyword ) !== false ) { |
| 182 |
$categories[] = 'marketing'; |
| 183 |
break; |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
// Social Media check (Exclude testimonials as requested) |
| 188 |
if ( stripos( $name, 'testimonial' ) === false && stripos( $slug, 'testimonial' ) === false ) { |
| 189 |
$is_social = false; |
| 190 |
|
| 191 |
// Check manual names |
| 192 |
foreach ( $social_manual_names as $s_name ) { |
| 193 |
if ( stripos( $name, $s_name ) !== false ) { |
| 194 |
$is_social = true; |
| 195 |
break; |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
// Check keywords if not already matched |
| 200 |
if ( ! $is_social ) { |
| 201 |
foreach ( $social_keywords as $s_keyword ) { |
| 202 |
if ( stripos( $name, $s_keyword ) !== false || stripos( $slug, $s_keyword ) !== false ) { |
| 203 |
$is_social = true; |
| 204 |
break; |
| 205 |
} |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
if ( $is_social ) { |
| 210 |
$categories[] = 'social'; |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
$plugin['ag_categories'] = $categories; |
| 215 |
$filtered_plugins[] = (object) $plugin; |
| 216 |
} |
| 217 |
|
| 218 |
// Sort by active installs descending (default for "All" tab on page load) |
| 219 |
usort( $filtered_plugins, function ( $a, $b ) { |
| 220 |
$a = (array) $a; |
| 221 |
$b = (array) $b; |
| 222 |
$a_installs = isset($a['active_installs']) ? (int) $a['active_installs'] : 0; |
| 223 |
$b_installs = isset($b['active_installs']) ? (int) $b['active_installs'] : 0; |
| 224 |
return $b_installs - $a_installs; |
| 225 |
} ); |
| 226 |
|
| 227 |
?> |
| 228 |
<div class="wrap ag-our-plugins-wrap"> |
| 229 |
<header class="ag-our-plugins-header"> |
| 230 |
<div class="ag-header-content"> |
| 231 |
<h1><?php esc_html_e( 'Our WordPress Ecosystem', 'testimonial-maker' ); ?></h1> |
| 232 |
<p><?php esc_html_e( 'Discover powerful tools designed to simplify your WordPress workflow. High-performance plugins built by A WP Life.', 'testimonial-maker' ); ?></p> |
| 233 |
</div> |
| 234 |
<div class="ag-header-stats"> |
| 235 |
<div class="ag-stat-item"> |
| 236 |
<span class="ag-stat-value">500k+</span> |
| 237 |
<span class="ag-stat-label"><?php esc_html_e( 'Active Installs', 'testimonial-maker' ); ?></span> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
</header> |
| 241 |
|
| 242 |
<!-- Category Filters --> |
| 243 |
<nav class="ag-plugins-filters"> |
| 244 |
<button class="ag-filter-btn active" data-filter="all"><?php esc_html_e( 'All Plugins', 'testimonial-maker' ); ?></button> |
| 245 |
<button class="ag-filter-btn" data-filter="new"><?php esc_html_e( 'New Releases', 'testimonial-maker' ); ?></button> |
| 246 |
<button class="ag-filter-btn" data-filter="popular"><?php esc_html_e( 'Most Popular', 'testimonial-maker' ); ?></button> |
| 247 |
<button class="ag-filter-btn" data-filter="marketing"><?php esc_html_e( 'Marketing & Growth', 'testimonial-maker' ); ?></button> |
| 248 |
<button class="ag-filter-btn" data-filter="social"><?php esc_html_e( 'Social Media', 'testimonial-maker' ); ?></button> |
| 249 |
<button class="ag-filter-btn" data-filter="technical"><?php esc_html_e( 'Technical Tools', 'testimonial-maker' ); ?></button> |
| 250 |
|
| 251 |
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'refresh_plugins', '1' ), 'ag_refresh_plugins' ) ); ?>" class="ag-refresh-link" title="<?php esc_attr_e( 'Sync with WordPress.org', 'testimonial-maker' ); ?>"> |
| 252 |
<span class="dashicons dashicons-update"></span> |
| 253 |
</a> |
| 254 |
</nav> |
| 255 |
|
| 256 |
<?php if ( empty( $filtered_plugins ) ) : ?> |
| 257 |
<div class="ag-error-wrap"> |
| 258 |
<span class="dashicons dashicons-warning"></span> |
| 259 |
<h2><?php esc_html_e( 'Unable to fetch our plugins', 'testimonial-maker' ); ?></h2> |
| 260 |
<p><?php esc_html_e( 'We encountered an error connecting to WordPress.org. Please try again later.', 'testimonial-maker' ); ?></p> |
| 261 |
<a href="<?php echo esc_url( 'https://profiles.wordpress.org/awordpresslife/#content-plugins' ); ?>" target="_blank" class="ag-btn ag-btn-primary" style="margin-top: 20px;"> |
| 262 |
<?php esc_html_e( 'Visit Our WordPress Profile', 'testimonial-maker' ); ?> |
| 263 |
</a> |
| 264 |
</div> |
| 265 |
<?php else : ?> |
| 266 |
<div class="ag-plugins-grid" id="ag-plugins-container"> |
| 267 |
<?php foreach ( $filtered_plugins as $plugin ) : |
| 268 |
$plugin = (array) $plugin; |
| 269 |
$icons = isset($plugin['icons']) ? (array) $plugin['icons'] : array(); |
| 270 |
$icon = ! empty( $icons['2x'] ) ? $icons['2x'] : ( ! empty( $icons['1x'] ) ? $icons['1x'] : '' ); |
| 271 |
|
| 272 |
$banners = isset($plugin['banners']) ? (array) $plugin['banners'] : array(); |
| 273 |
$banner = ! empty( $banners['high'] ) ? $banners['high'] : ( ! empty( $banners['low'] ) ? $banners['low'] : '' ); |
| 274 |
|
| 275 |
if ( empty( $banner ) ) { |
| 276 |
$banner = 'https://s.w.org/plugins/geopattern-icon/' . $plugin['slug'] . '.svg'; |
| 277 |
} |
| 278 |
|
| 279 |
$rating = isset($plugin['rating']) ? $plugin['rating'] : 0; |
| 280 |
$stars = ( $rating / 100 ) * 5; |
| 281 |
|
| 282 |
$active_installs = isset($plugin['active_installs']) ? $plugin['active_installs'] : 0; |
| 283 |
$install_count = $active_installs >= 1000 ? ( floor( $active_installs / 1000 ) . 'k+' ) : $active_installs; |
| 284 |
|
| 285 |
$is_installed = file_exists( WP_PLUGIN_DIR . '/' . $plugin['slug'] ); |
| 286 |
|
| 287 |
// Categories for JS filtering |
| 288 |
$cat_classes = implode( ' ', array_map( function($c) { return 'cat-' . $c; }, $plugin['ag_categories'] ) ); |
| 289 |
$plugin_slug = isset($plugin['slug']) ? $plugin['slug'] : ''; |
| 290 |
$manual_index = array_search( $plugin_slug, $manual_slug_order ); |
| 291 |
if ( $manual_index === false ) { |
| 292 |
$manual_index = 999; |
| 293 |
} |
| 294 |
?> |
| 295 |
<div class="ag-plugin-card <?php echo esc_attr( $cat_classes ); ?>" data-installs="<?php echo (int) $active_installs; ?>" data-manual-order="<?php echo (int) $manual_index; ?>"> |
| 296 |
<?php if ( $is_installed ) : ?> |
| 297 |
<div class="ag-plugin-status"><?php esc_html_e( 'INSTALLED', 'testimonial-maker' ); ?></div> |
| 298 |
<?php endif; ?> |
| 299 |
|
| 300 |
<div class="ag-plugin-banner"> |
| 301 |
<img src="<?php echo esc_url( $banner ); ?>" alt="<?php echo esc_attr( $plugin['name'] ); ?>"> |
| 302 |
</div> |
| 303 |
|
| 304 |
<div class="ag-plugin-content"> |
| 305 |
<h2><?php echo esc_html( $plugin['name'] ); ?></h2> |
| 306 |
<div class="ag-plugin-description"> |
| 307 |
<?php echo esc_html( wp_trim_words( $plugin['short_description'], 18 ) ); ?> |
| 308 |
</div> |
| 309 |
|
| 310 |
<div class="ag-plugin-meta"> |
| 311 |
<div class="ag-plugin-meta-item" title="<?php echo esc_attr( $rating ); ?>%"> |
| 312 |
<span class="dashicons dashicons-star-filled"></span> |
| 313 |
<?php echo esc_html( number_format( $stars, 1 ) ); ?> |
| 314 |
</div> |
| 315 |
<div class="ag-plugin-meta-item"> |
| 316 |
<span class="dashicons dashicons-download"></span> |
| 317 |
<?php echo esc_html( $install_count ); ?> <?php esc_html_e( 'Installs', 'testimonial-maker' ); ?> |
| 318 |
</div> |
| 319 |
</div> |
| 320 |
|
| 321 |
<div class="ag-plugin-actions"> |
| 322 |
<a href="<?php echo esc_url( 'https://wordpress.org/plugins/' . $plugin['slug'] . '/' ); ?>" target="_blank" class="ag-btn ag-btn-secondary"> |
| 323 |
<?php esc_html_e( 'Details', 'testimonial-maker' ); ?> |
| 324 |
</a> |
| 325 |
<a href="<?php echo esc_url( admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . '&TB_iframe=true&width=772&height=550' ) ); ?>" class="ag-btn ag-btn-primary thickbox"> |
| 326 |
<?php esc_html_e( 'Install Now', 'testimonial-maker' ); ?> |
| 327 |
</a> |
| 328 |
</div> |
| 329 |
</div> |
| 330 |
</div> |
| 331 |
<?php endforeach; ?> |
| 332 |
</div> |
| 333 |
<?php endif; ?> |
| 334 |
</div> |
| 335 |
|
| 336 |
<script> |
| 337 |
jQuery(document).ready(function($) { |
| 338 |
$('.ag-filter-btn').on('click', function() { |
| 339 |
var filter = $(this).data('filter'); |
| 340 |
|
| 341 |
// Update active button |
| 342 |
$('.ag-filter-btn').removeClass('active'); |
| 343 |
$(this).addClass('active'); |
| 344 |
|
| 345 |
var $container = $('#ag-plugins-container'); |
| 346 |
var $cards = $container.children('.ag-plugin-card'); |
| 347 |
|
| 348 |
if (filter === 'all') { |
| 349 |
// Sort by active installs descending |
| 350 |
$cards.sort(function(a, b) { |
| 351 |
var valA = parseInt($(a).attr('data-installs')) || 0; |
| 352 |
var valB = parseInt($(b).attr('data-installs')) || 0; |
| 353 |
return valB - valA; |
| 354 |
}); |
| 355 |
$container.append($cards); |
| 356 |
$('.ag-plugin-card').fadeIn(300); |
| 357 |
} else { |
| 358 |
// Sort by manual order ascending |
| 359 |
$cards.sort(function(a, b) { |
| 360 |
var valA = $(a).attr('data-manual-order'); |
| 361 |
var valB = $(b).attr('data-manual-order'); |
| 362 |
|
| 363 |
valA = (valA !== undefined && valA !== '') ? parseInt(valA) : 999; |
| 364 |
valB = (valB !== undefined && valB !== '') ? parseInt(valB) : 999; |
| 365 |
|
| 366 |
if (isNaN(valA)) { valA = 999; } |
| 367 |
if (isNaN(valB)) { valB = 999; } |
| 368 |
|
| 369 |
// If both are not in manual list (both 999), fall back to installs descending |
| 370 |
if (valA === 999 && valB === 999) { |
| 371 |
var instA = parseInt($(a).attr('data-installs')) || 0; |
| 372 |
var instB = parseInt($(b).attr('data-installs')) || 0; |
| 373 |
return instB - instA; |
| 374 |
} |
| 375 |
return valA - valB; |
| 376 |
}); |
| 377 |
$container.append($cards); |
| 378 |
$('.ag-plugin-card').hide(); |
| 379 |
$('.cat-' + filter).fadeIn(300); |
| 380 |
} |
| 381 |
}); |
| 382 |
}); |
| 383 |
</script> |
| 384 |
|