- 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>
261 lines
5.6 KiB
PHP
Executable File
261 lines
5.6 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* Database functions
|
|
*
|
|
* @link https://raiolanetworks.es
|
|
* @since 1.0.0
|
|
*
|
|
* @package Wp_Database_Tools
|
|
* @subpackage Wp_Database_Tools/includes
|
|
*/
|
|
|
|
/**
|
|
* Contains the functionalities related to database management.
|
|
*
|
|
* This class defines all code necessary to manage the database functionalities.
|
|
*
|
|
* @since 1.0.0
|
|
* @package Wp_Database_Tools
|
|
* @subpackage Wp_Database_Tools/includes
|
|
* @author Raiola Networks <info@raiolanetworks.es>
|
|
*/
|
|
|
|
class Wp_Database_Tools_Database_Data {
|
|
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var int $likes The general data of database.
|
|
*/
|
|
protected $id;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var int $likes The general data of database.
|
|
*/
|
|
protected $name;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var int $dislikes The general data of database.
|
|
*/
|
|
protected $feedback;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $multiple;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var Wp_Database_Tools_Database_Data_Origin $origin The general data of database.
|
|
*/
|
|
public $origin;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $check;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $size;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $format_size;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $section;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $regex;
|
|
|
|
/**
|
|
* The general data of database.
|
|
*
|
|
* @since 1.0.0
|
|
* @access protected
|
|
* @var array $data The general data of database.
|
|
*/
|
|
protected $value;
|
|
|
|
public function __construct() {
|
|
|
|
$admin_url = plugin_dir_url( __DIR__ ) . 'admin/';
|
|
|
|
$this->origin = new Wp_Database_Tools_Database_Data_Origin();
|
|
$this->multiple = false;
|
|
$this->reliability = '-';
|
|
$this->check = false;
|
|
}
|
|
|
|
|
|
public function get_matching_data( $matching, $plugins, $themes, $name ) {
|
|
|
|
$data_value = null;
|
|
|
|
if ( $this->section == 'options' ) {
|
|
$data_value = ( $this->value == '' ) ? null : $this->value;
|
|
}
|
|
|
|
$slug_concidence_plugins = $matching->find_match( 'plugin', $name, $data_value );
|
|
$slug_concidence_themes = $matching->find_match( 'theme', $name, $data_value );
|
|
|
|
$concidence = false;
|
|
|
|
if ( ! empty( $slug_concidence_plugins ) && ! empty( $slug_concidence_themes ) ) {
|
|
|
|
// Set the better coincidence
|
|
$type = ( $slug_concidence_plugins['match'] >= $slug_concidence_themes['match'] ) ? 'plugin' : 'theme';
|
|
$coincidence_data = ( $type == 'plugin' ) ? $slug_concidence_plugins : $slug_concidence_themes;
|
|
$concidence = true;
|
|
} elseif ( ! empty( $slug_concidence_plugins ) ) {
|
|
|
|
$type = 'plugin';
|
|
$coincidence_data = $slug_concidence_plugins;
|
|
$concidence = true;
|
|
} elseif ( ! empty( $slug_concidence_themes ) ) {
|
|
|
|
$type = 'theme';
|
|
$coincidence_data = $slug_concidence_themes;
|
|
$concidence = true;
|
|
}
|
|
|
|
if ( $concidence == true ) {
|
|
|
|
if ( $type == 'plugin' ) {
|
|
$key = array_search( $coincidence_data['slug'], array_column( $plugins, 'slug' ) );
|
|
$data['origin'] = $plugins[ array_keys( $plugins )[ $key ] ];
|
|
}
|
|
|
|
if ( $type == 'theme' ) {
|
|
|
|
$key = array_search( $coincidence_data['slug'], array_column( $themes, 'slug' ) );
|
|
$data['origin'] = $themes[ array_keys( $themes )[ $key ] ];
|
|
}
|
|
|
|
if ( is_null( $data['origin'] ) ) {
|
|
return null;
|
|
}
|
|
|
|
$data['type'] = $type;
|
|
$data['length'] = strlen( $coincidence_data['slug'] );
|
|
$data['match'] = $coincidence_data['match'];
|
|
return $data;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public function set_feedback( $feedback ) {
|
|
|
|
if ( isset( $feedback ) ) {
|
|
$feedback = (array) $feedback;
|
|
$this->feedback = isset( $feedback[ $this->name ] );
|
|
} else {
|
|
$this->feedback = false;
|
|
}
|
|
}
|
|
|
|
public function set_data_by_algorithm( $data_algorithm ) {
|
|
$this->origin->set_origin_by_algorithm( $data_algorithm );
|
|
}
|
|
|
|
public function sum_size( $row ) {
|
|
|
|
if ( isset( $row->Data_length ) && isset( $row->Index_length ) ) {
|
|
$sum = $row->Data_length + $row->Index_length;
|
|
} else {
|
|
$sum = 0;
|
|
}
|
|
|
|
return $sum;
|
|
}
|
|
|
|
public function get_file_size_info( $file_size ) {
|
|
|
|
$bytes = array( 'B', 'KB', 'MB', 'GB', 'TB' );
|
|
|
|
if ( $file_size < 1024 ) {
|
|
$file_size = 1;
|
|
}
|
|
|
|
for ( $i = 0; $file_size > 1024; $i++ ) {
|
|
$file_size /= 1024;
|
|
}
|
|
|
|
$db_size_info['size'] = round( $file_size, 2 );
|
|
$db_size_info['type'] = $bytes[ $i ];
|
|
|
|
return $db_size_info;
|
|
}
|
|
|
|
public function get_name() {
|
|
return $this->name;
|
|
}
|
|
public function get_size() {
|
|
return $this->size;
|
|
}
|
|
|
|
public function get_origin() {
|
|
return $this->origin;
|
|
}
|
|
|
|
public function get_regex() {
|
|
return $this->regex;
|
|
}
|
|
|
|
public function set_origin( $value ) {
|
|
$this->origin = $value;
|
|
}
|
|
|
|
public function set_regex( $value ) {
|
|
$this->regex = $value;
|
|
}
|
|
}
|