$plugin_slug,
'fields' => array(
'name' => true,
'short_description' => true,
'active_installs' => true,
'icons' => true,
'last_updated' => true,
'num_ratings' => true,
'rating' => true,
'ratings' => true,
'screenshots' => true,
'slug' => true,
'version' => true,
'versions' => true,
'downloaded' => true,
),
);
// Fetch plugin data using plugins_api.
$extras_info = plugins_api( 'plugin_information', $args );
// Proceed if plugin data is available.
if ( ! is_wp_error( $extras_info ) ) {
$extras_name = $extras_info->name;
$extras_rating = $extras_info->rating;
$extras_installs = $extras_info->active_installs;
$extras_last_updated = $extras_info->last_updated;
$extras_icons = $extras_info->icons;
$extras_author = $extras_info->author;
$extras_ratings = $extras_info->ratings;
$extras_downloaded = $extras_info->downloaded;
$extras_short_description = $extras_info->short_description;
// Fetch image source and name from icons.
$src = isset( $extras_icons['2x'] ) ? $extras_icons['2x'] : ( isset( $extras_icons['1x'] ) ? $extras_icons['1x'] : '' );
$alt = esc_html( $extras_name ) . ( isset( $extras_icons['2x'] ) ? ' 2x' : ( isset( $extras_icons['1x'] ) ? ' 1x' : '' ) );
// Iterate through the ratings and construct the star rating HTML.
// Calculate the average rating.
$total_ratings = 0;
$total_count = 0;
foreach ( $extras_ratings as $rating => $count ) {
$total_ratings += ( $rating * $count );
$total_count += $count;
}
$average_rating = round( $total_count > 0 ? $total_ratings / $total_count : 0 );
// Determine the number of filled stars and half star based on the average rating.
$filled_stars = floor( $average_rating );
$half_star = round( $average_rating - $filled_stars, 1 ) >= 0.5;
// Construct the star rating HTML.
$star_rating_html = '
';
// Filled stars.
for ( $i = 0; $i < $filled_stars; $i++ ) {
$star_rating_html .= '';
}
// Half star.
if ( $half_star ) {
$star_rating_html .= '';
}
// Empty stars.
for ( $i = 0; $i < 5 - $filled_stars - $half_star; $i++ ) {
$star_rating_html .= '';
}
$star_rating_html .= '
';
// Finished Stars.
if ( $plugin_slug === 'slider-factory' ) {
// Trim the name to 7 words.
$name_words = explode( ' ', $extras_name );
$extras_name = implode( ' ', array_slice( $name_words, 0, 2 ) );
}
/** Install Update Button */
// Set the plugin slug and other installation information.
$plugin_info = $extras_info;
// Check if the plugin information is available.
if ( ! is_wp_error( $plugin_info ) ) {
// Check the installation status.
$plugin_install_status = install_plugin_install_status( $plugin_info );
// Generate installation link based on the installation status.
switch ( $plugin_install_status['status'] ) {
case 'install':
$plugin_button = '
';
break;
case 'update_available':
$plugin_button = '
';
break;
case 'latest_installed':
case 'newer_installed':
// Plugin is already installed and up to date.
$plugin_name = $plugin_slug . '/' . $plugin_slug . '.php';
if ( is_plugin_active( $plugin_name ) ) {
$plugin_button = '
';
} else {
$plugin_button = '
';
}
break;
}
}
/** End Install Update Button */
?>
Total Downloads : +
Author :
array(
'href' => array(),
'onclick' => array(),
'class' => array(),
),
);
?>
';
}
?>
$theme_slug,
'fields' => array(
'name' => true,
'downloaded' => true,
'theme_url' => true,
'active_installs' => true,
'screenshot_url' => true,
'last_updated' => true,
'num_ratings' => true,
'rating' => true,
'ratings' => true,
'version' => true,
'preview_url' => true,
'parent' => true,
'author' => true,
'sections' => true,
),
);
$thm_extras_info = themes_api( 'theme_information', $thm_args );
// Proceed if theme data is available.
if ( ! is_wp_error( $thm_extras_info ) ) {
$thm_name = $thm_extras_info->name;
$thm_downloaded = $thm_extras_info->downloaded;
$thm_theme_url = $thm_extras_info->theme_url;
$thm_installs = $thm_extras_info->active_installs;
$thm_screenshot_url = $thm_extras_info->screenshot_url;
$thm_last_updated = $thm_extras_info->last_updated;
$thm_num_ratings = $thm_extras_info->num_ratings;
$thm_rating = $thm_extras_info->rating;
$thm_ratings = $thm_extras_info->ratings;
$thm_version = $thm_extras_info->version;
$thm_preview_url = $thm_extras_info->preview_url;
$thm_author = $thm_extras_info->author;
// var_dump( $thm_preview_url );
if ( isset( $thm_extras_info->parent ) ) {
// Parent property exists.
$thm_parent = $thm_extras_info->parent;
}
// Iterate through the ratings and construct the star rating HTML.
// Calculate the average rating.
$total_ratings = 0;
$total_count = 0;
foreach ( $thm_ratings as $rating => $count ) {
$total_ratings += ( $rating * $count );
$total_count += $count;
}
$average_rating = $total_count > 0 ? $total_ratings / $total_count : 0;
// Determine the number of filled stars and half star based on the average rating.
$filled_stars = floor( $average_rating );
$half_star = round( $average_rating - $filled_stars, 1 ) >= 0.5;
// Construct the star rating HTML.
$star_rating_html = '
';
// Filled stars.
for ( $i = 0; $i < $filled_stars; $i++ ) {
$star_rating_html .= '';
}
// Half star.
if ( $half_star ) {
$star_rating_html .= '';
}
// Empty stars.
for ( $i = 0; $i < 5 - $filled_stars - $half_star; $i++ ) {
$star_rating_html .= '';
}
$star_rating_html .= '
';
// Finished Stars.
// Get the theme information.
$theme_info = wp_get_theme( $theme_slug );
// Check if the theme directory exists.
$is_installed = is_dir( get_theme_root() . '/' . $theme_slug );
// Check if the theme information is available and the theme is installed.
if ( $theme_info->exists() && $is_installed ) {
$current_theme = wp_get_theme();
$is_active = $current_theme->get_stylesheet() === $theme_info->get_stylesheet();
$current_version = $theme_info->get( 'Version' );
$latest_version = $thm_version;
// Generate buttons based on the installation, update, and activation status.
if ( version_compare( $current_version, $latest_version, '<' ) ) {
$theme_button = '
';
} elseif ( $is_active ) {
$theme_button = '
';
} else {
$theme_button = '
Activate Now';
}
} else {
$theme_button = '
';
}
// Construct the theme card HTML.
?>
Child theme of :
Total Downloads : +
Author :
Author Web:
array(
'href' => array(),
'onclick' => array(),
'class' => array(),
'type' => array(),
),
'button' => array(
'href' => array(),
'onclick' => array(),
'class' => array(),
'type' => array(),
),
);
?>
Pro Demo
Buy Now
';
}
}
// var_dump( $thm_extras_info );
?>