Files
roi-theme/wp-content/plugins/wp-database-tools/includes/class-wp-database-tools-themes.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

130 lines
3.1 KiB
PHP
Executable File

<?php
/**
* Database functions
*
* @link https://raiolanetworks.es
* @since 1.0.0
*
* @package Wp_Database_Tools
* @subpackage Wp_Database_Tools/includes
*/
/**
* Detects current plugins in the installation
* *
*
* @since 1.0.0
* @package Wp_Database_Tools
* @subpackage Wp_Database_Tools/includes
* @author Patricia Alvarez <patricia@raiolanetworks.es>
*/
class Wp_Database_Tools_Themes {
/**
* Plugins in the installation.
*
* @since 1.0.0
* @access protected
* @var array $data The general data of database.
*/
protected $themes;
public function __construct() {
$this->init();
}
protected function init() {
$this->format_themes();
}
protected function format_themes() {
$themes_data = array();
foreach ( wp_get_themes() as $key => $theme ) {
// Check marketplace.
$marketplace = 'unknown';
if ( str_contains( $theme['AuthorURI'], 'codecanyon' ) || str_contains( $theme['ThemeURI'], 'codecanyon' ) ) {
$marketplace = 'https://codecanyon.net';
}
if ( str_contains( $theme['AuthorURI'], 'themeforest' ) || str_contains( $theme['ThemeURI'], 'themeforest' ) ) {
$marketplace = 'https://themeforest.net';
}
if ( str_contains( $theme['AuthorURI'], 'wordpress.org' ) || str_contains( $theme['ThemeURI'], 'wordpress.org' ) ) {
$marketplace = 'https://wordpress.org';
}
$themes_data[ $key ]['name'] = $theme->get( 'Name' ) ?? $key;
$themes_data[ $key ]['marketplace'] = $marketplace;
$themes_data[ $key ]['slug'] = $key;
$themes_data[ $key ]['initials'] = $this->get_initials( $key );
$themes_data[ $key ]['status'] = $this->get_theme_status( $key );
$themes_data[ $key ]['author'] = $theme->get( 'Author' ) ?? null;
$themes_data[ $key ]['author_name'] = $theme->get( 'Author' ) ?? null;
$themes_data[ $key ]['author_url'] = $theme->get( 'ThemeURI' ) ?? null;
$themes_data[ $key ]['version'] = $theme['Version'] ?? null;
}
$this->themes = $themes_data;
}
/**
* Get's the activation status for a plugin.
*
* @since 5.5.0
*
* @param string $plugin The plugin file to check.
* @return string 'active' . 'inactive' or 'uninstalled'.
* @author Patricia Alvarez <patricia@raiolanetworks.es>
*/
protected function get_theme_status( $theme ) {
if ( $theme === get_option( 'template' ) ) {
return 'active';
} elseif ( file_exists( get_theme_root() . '/' . $theme ) ) {
return 'inactive';
}
}
/**
* Get's the initials.
*
* @since 1.0.0
*
* @param string $plugin The plugin file to check.
* @return string 'active' . 'inactive' or 'uninstalled'.
* @author Patricia Alvarez <patricia@raiolanetworks.es>
*/
public function get_initials( $input ) {
$words = preg_split( '/[\s,_-]+/', $input );
$initials = '';
foreach ( $words as $input => $word ) {
$initials .= substr( $word, 0, 1 );
}
return $initials;
}
/**
* Get's the activation status for a plugin.
*
* @since 5.5.0
*
* @return string 'active' . 'inactive' or 'uninstalled'.
* @author Patricia Alvarez <patricia@raiolanetworks.es>
*/
public function get_themes() {
return $this->themes;
}
}