| Server IP : 146.190.157.162 / Your IP : 216.73.217.6 Web Server : Apache System : Linux ubuntu-s-2vcpu-4gb-amd-sfo3-01-KIT-DIGITAL 6.5.0-44-generic #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024 x86_64 User : businessweek ( 639) PHP Version : 8.2.10-2ubuntu2.2 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_signal,pcntl_signal_dispatch,pcntl_getpriority,pcntl_setpriority,dl,putenv,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/ansiosos/wp-content/plugins/redirection/models/importer/ |
Upload File : |
<?php
/**
* @phpstan-type ImporterInfo array{
* id: string,
* name: string,
* total: int
* }
*/
abstract class Red_Plugin_Importer {
/**
* @return list<array{id: string, name: string, total: int}>
*/
public static function get_plugins(): array {
$results = array();
$importers = array(
'wp-simple-redirect',
'seo-redirection',
'safe-redirect-manager',
'wordpress-old-slugs',
'rank-math',
'quick-redirects',
'pretty-links',
);
foreach ( $importers as $importer_id ) {
$importer = self::get_importer( $importer_id );
if ( ! $importer instanceof Red_Plugin_Importer ) {
continue;
}
$data = $importer->get_data();
if ( $data === false || $data['total'] === 0 ) {
continue;
}
$results[] = $data;
}
return $results;
}
/**
* Get an importer instance by ID.
*
* @param string $id Importer identifier.
* @return Red_Plugin_Importer|false
*/
public static function get_importer( string $id ) {
if ( $id === 'wp-simple-redirect' ) {
return new Red_Simple301_Importer();
}
if ( $id === 'seo-redirection' ) {
return new Red_SeoRedirection_Importer();
}
if ( $id === 'safe-redirect-manager' ) {
return new Red_SafeRedirectManager_Importer();
}
if ( $id === 'wordpress-old-slugs' ) {
return new Red_WordPressOldSlug_Importer();
}
if ( $id === 'rank-math' ) {
return new Red_RankMath_Importer();
}
if ( $id === 'quick-redirects' ) {
return new Red_QuickRedirect_Importer();
}
if ( $id === 'pretty-links' ) {
return new Red_PrettyLinks_Importer();
}
return false;
}
/**
* Import all redirects for a plugin ID into a target group.
*
* @param string $plugin Importer identifier.
* @param int $group_id Target group ID.
* @return int Number of imported redirects.
*/
public static function import( $plugin, $group_id ) {
$importer = self::get_importer( $plugin );
if ( $importer !== false ) {
return $importer->import_plugin( $group_id );
}
return 0;
}
/**
* Import using a specific importer instance.
*
* @param int $group_id Target group ID.
* @return int Number of imported redirects.
*/
abstract public function import_plugin( $group_id );
/**
* Get importer summary data used by UI/CLI.
*
* @return ImporterInfo|false
*/
abstract public function get_data();
}