n false;
}
return true;
}
/**
* Match and cache regular redirects for a URL.
*
* @since 1.2.3
*
* @param string $requestUrl The full request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array An array of matched redirects.
*/
public function getRegularRedirects( $requestUrl, $enabled = 1 ) {
$requestUrl = Utils\WpUri::excludeHomeUrl( $requestUrl );
$redirects = aioseoRedirects()->cache->getRedirects( $requestUrl );
if ( null === $redirects ) {
$redirects = $this->matchRegularRedirects( $requestUrl, $enabled );
aioseoRedirects()->cache->setRedirects( $requestUrl, $redirects );
}
return $redirects;
}
/**
* Matches redirects for a URL.
*
* @since 1.2.3
*
* @param string $requestUrl The full request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array An array of matched redirects.
*/
private function matchRegularRedirects( $requestUrl, $enabled = 1 ) {
$requestUrlNoQuery = wp_parse_url( $requestUrl, PHP_URL_PATH ) ?: '/';
$redirects = $this->getRedirectsBySource( $requestUrlNoQuery, $enabled );
foreach ( $redirects as $key => $redirect ) {
if ( ! $this->matchRedirect( $redirect, $requestUrl ) ) {
unset( $redirects[ $key ] );
}
}
return $redirects ?: [];
}
/**
* Match and cache regex redirects for a URL.
*
* @since 1.2.3
*
* @param string $requestUrl The request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array The regex redirects.
*/
public function getRegexRedirects( $requestUrl, $enabled = 1 ) {
$requestUrl = Utils\WpUri::excludeHomeUrl( $requestUrl );
$redirects = aioseoRedirects()->cache->getRedirects( 'regex:' . $requestUrl );
if ( null === $redirects ) {
$redirects = $this->matchRegexRedirects( $requestUrl, $enabled );
aioseoRedirects()->cache->setRedirects( 'regex:' . $requestUrl, $redirects );
}
return $redirects;
}
/**
* Matches redirects for a URL.
*
* @since 1.2.3
*
* @param string $requestUrl The full request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array An array of matched redirects.
*/
public function matchRegexRedirects( $requestUrl, $enabled = 1 ) {
$redirects = $this->getAllRegexRedirects( $enabled );
foreach ( $redirects as $key => &$redirect ) {
$matches = $this->matchRedirect( $redirect, $requestUrl );
if ( empty( $matches ) ) {
unset( $redirects[ $key ] );
continue;
}
$redirect->regexMatches = $matches;
}
return $redirects ?: [];
}
/**
* Gets all redirects for a URL. This is not cached and used for the Redirects post metabox.
*
* @since 1.1.7
*
* @param string $requestUrl The full request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array An array of matched redirects.
*/
public function getRedirects( $requestUrl, $enabled = 1 ) {
$requestUrl = Utils\WpUri::excludeHomeUrl( $requestUrl );
return array_merge(
$this->matchRegularRedirects( $requestUrl, $enabled ),
$this->matchRegexRedirects( $requestUrl, $enabled )
);
}
/**
* Return all redirects for a source.
*
* @since 1.1.7
*
* @param string $requestUrl The request url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array The redirects.
*/
public function getRedirectsBySource( $requestUrl, $enabled = 1 ) {
$requestUrlNoQuery = wp_parse_url( $requestUrl );
$requestUrlNoQuery = ! empty( $requestUrlNoQuery['path'] ) ? $requestUrlNoQuery['path'] : '/';
$query = aioseo()->core->db->start( 'aioseo_redirects' )
->where( 'source_url_match_hash', Utils\Request::getMatchedUrlHash( $requestUrlNoQuery ) )
->orderBy( 'id DESC' );
if ( 'all' !== $enabled ) {
$query->where( 'enabled', $enabled );
}
return $query->run()->models( 'AIOSEO\\Plugin\\Addon\\Redirects\\Models\\Redirect' );
}
/**
* Return all redirects for a target.
*
* @since 1.2.7
*
* @param string $targetUrl The target url.
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array The redirects.
*/
public function getRedirectsByTarget( $targetUrl, $enabled = 1 ) {
$targetUrlNoQuery = wp_parse_url( $targetUrl );
$targetUrlNoQuery = ! empty( $targetUrlNoQuery['path'] ) ? $targetUrlNoQuery['path'] : '/';
$query = aioseo()->core->db->start( 'aioseo_redirects' )
->where( 'target_url_hash', Utils\Request::getUrlHash( $targetUrlNoQuery ) )
->orderBy( 'id DESC' );
if ( 'all' !== $enabled ) {
$query->where( 'enabled', $enabled );
}
return $query->run()->models( 'AIOSEO\\Plugin\\Addon\\Redirects\\Models\\Redirect' );
}
/**
* Return all regex redirects.
*
* @since 1.2.3
*
* @param int|string $enabled Enabled redirects 1|0|all.
* @return array The regex redirects.
*/
private function getAllRegexRedirects( $enabled ) {
$query = aioseo()->core->db->start( 'aioseo_redirects' )
->where( 'source_url_match_hash', Utils\Request::getRegexHash() )
->orderBy( 'id DESC' );
if ( 'all' !== $enabled ) {
$query->where( 'enabled', $enabled );
}
return $query->run()->models( 'AIOSEO\\Plugin\\Addon\\Redirects\\Models\\Redirect' );
}
/**
* Checks whether the current request is for a page builder preview.
* If so, don't need to check for redirects because we'll otherwise break page builder.
*
* @since 1.3.3
*
* @return bool Whether the current request is for the page builder preview.
*/
private function isPageBuilderPreviewRequest() {
$pageBuilderRequest = [
'elementor' => [ 'elementor-preview' ],
'wpbakery' => [ 'vc_editable' ],
'avada' => [ 'fb-edit', 'builder_id' ],
'divi' => [ 'et_fb' ]
];
foreach ( $pageBuilderRequest as $pageBuilder => $possibleRequests ) {
foreach ( $possibleRequests as $request ) {
if ( ! empty( $_REQUEST[ $request ] ) ) { // phpcs:ignore HM.Security.NonceVerification.Recommended
return isset( aioseo()->standalone->pageBuilderIntegrations[ $pageBuilder ] ) && aioseo()->standalone->pageBuilderIntegrations[ $pageBuilder ]->isActive();
}
}
}
return false;
}
/**
* Return a redirect for a post id.
*
* @since 1.2.7
*
* @param int $postId The post ID.
* @return Models\Redirect The redirect tied to the post id.
*/
public function getRedirectByPostId( $postId ) {
$query = aioseo()->core->db->start( 'aioseo_redirects' )->where( 'post_id', $postId )->orderBy( 'id DESC' );
// This assumes there's only one tied redirect at any given time.
return $query->run()->model( 'AIOSEO\\Plugin\\Addon\\Redirects\\Models\\Redirect' );
}
}
Fatal error: Uncaught Error: Class "AIOSEO\Plugin\Addon\Redirects\Main\Redirect" not found in /home/valigeria/public_html/wp-content/plugins/aioseo-redirects/app/Redirects.php:259
Stack trace:
#0 /home/valigeria/public_html/wp-content/plugins/aioseo-redirects/app/Redirects.php(184): AIOSEO\Plugin\Addon\Redirects\Redirects->load()
#1 /home/valigeria/public_html/wp-content/plugins/aioseo-redirects/app/Redirects.php(286): AIOSEO\Plugin\Addon\Redirects\Redirects::instance()
#2 /home/valigeria/public_html/wp-content/plugins/aioseo-redirects/aioseo-redirects.php(119): aioseoRedirects()
#3 /home/valigeria/public_html/wp-includes/class-wp-hook.php(324): aioseo_redirects_load('')
#4 /home/valigeria/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#5 /home/valigeria/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#6 /home/valigeria/public_html/wp-content/plugins/all-in-one-seo-pack-pro/app/AIOSEO.php(395): do_action('aioseo_loaded')
#7 /home/valigeria/public_html/wp-includes/class-wp-hook.php(324): AIOSEO\Plugin\AIOSEO->loadAddons('')
#8 /home/valigeria/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#9 /home/valigeria/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#10 /home/valigeria/public_html/wp-settings.php(563): do_action('sanitize_commen...')
#11 /home/valigeria/public_html/wp-config.php(111): require_once('/home/valigeria...')
#12 /home/valigeria/public_html/wp-load.php(50): require_once('/home/valigeria...')
#13 /home/valigeria/public_html/wp-blog-header.php(13): require_once('/home/valigeria...')
#14 /home/valigeria/public_html/index.php(17): require('/home/valigeria...')
#15 {main}
thrown in /home/valigeria/public_html/wp-content/plugins/aioseo-redirects/app/Redirects.php on line 259