| Server IP : 121.121.20.254 / Your IP : 216.73.216.146 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/aioseo-link-assistant/app/Main/ |
Upload File : |
<?php
namespace AIOSEO\Plugin\Addon\LinkAssistant\Main;
use AIOSEO\Plugin\Addon\LinkAssistant\Links;
use AIOSEO\Plugin\Addon\LinkAssistant\Suggestions;
use AIOSEO\Plugin\Addon\LinkAssistant\Models;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The main class where all the scan magic happens.
*
* @since 1.0.0
*/
class Main {
/**
* Paragraph class instance.
*
* @since 1.0.11
*
* @var Paragraph
*/
public $paragraph = null;
/**
* Links class instance.
*
* @since 1.0.11
*
* @var Links
*/
public $links = null;
/**
* Suggestions class instance.
*
* @since 1.0.11
*
* @var Suggestions
*/
public $suggestions = null;
/**
* Class constructor.
*
* @since 1.0.0
*/
public function __construct() {
if (
! aioseo()->core->db->tableExists( 'aioseo_links' ) ||
! aioseo()->core->db->tableExists( 'aioseo_links_suggestions' )
) {
aioseoLinkAssistant()->updates->addInitialTables();
aioseoLinkAssistant()->updates->addInitialColumns();
return;
}
$this->paragraph = new Paragraph();
$this->links = new Links\Links();
$this->suggestions = new Suggestions\Suggestions();
if ( ! is_admin() ) {
return;
}
add_action( 'delete_post', [ $this, 'removeOrphanedData' ] );
}
/**
* If a post is deleted, we should also remove any Link Assistant data for it.
*
* @since 1.0.0
*
* @return void
*/
public function removeOrphanedData( $postId ) {
Models\Link::deleteLinks( $postId );
// Delete all suggestions that originate from or point to the deleted post.
aioseo()->core->db->delete( 'aioseo_links_suggestions' )
->where( 'post_id', $postId )
->run();
aioseo()->core->db->delete( 'aioseo_links_suggestions' )
->where( 'linked_post_id', $postId )
->run();
}
}