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