v1.0.0
This commit is contained in:
parent
8caa140991
commit
5cdf7f48e5
29 changed files with 6526 additions and 0 deletions
58
includes/class-robotstxt-mlp2-mlp5-reader-site-relations.php
Normal file
58
includes/class-robotstxt-mlp2-mlp5-reader-site-relations.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/**
|
||||
* MLP2 site relations reader.
|
||||
*
|
||||
* Reads all site connection rows from the MLP2 backup site_relations table.
|
||||
*
|
||||
* MLP2 site_relations schema:
|
||||
* site_1 INT UNSIGNED -- lower site ID
|
||||
* site_2 INT UNSIGNED -- higher site ID
|
||||
* PRIMARY KEY (site_1, site_2)
|
||||
*
|
||||
* @package Robotstxt_Mlp2_Mlp5
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations
|
||||
*/
|
||||
class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations {
|
||||
|
||||
/**
|
||||
* Return all MLP2 site relation rows as an array of associative arrays.
|
||||
*
|
||||
* Each element has keys: site_1 (int), site_2 (int).
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public static function get_all(): array {
|
||||
global $wpdb;
|
||||
|
||||
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||
$table = $mlp2->get_site_relations_table();
|
||||
|
||||
if ( '' === $table ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||
$rows = $wpdb->get_results( "SELECT site_1, site_2 FROM `{$table}`", ARRAY_A );
|
||||
|
||||
if ( ! is_array( $rows ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ( $rows as $row ) {
|
||||
$result[] = array(
|
||||
'site_1' => (int) $row['site_1'],
|
||||
'site_2' => (int) $row['site_2'],
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue