File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Links.php.tar
www/vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/broken-link-checker-seo/app/Links/Links.php0000644 00000007723 15154657373 0030476 0 ustar 00 var <?php
namespace AIOSEO\BrokenLinkChecker\Links;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use AIOSEO\BrokenLinkChecker\Models;
/**
* Handles the Links scan.
*
* @since 1.0.0
*/
class Links {
/**
* The action name of the scan.
*
* @since 1.0.0
*
* @var string
*/
private $scanActionName = 'aioseo_blc_links_scan';
/**
* Data class instance.
*
* @since 1.1.0
*
* @var Data
*/
public $data = null;
/**
* Holds the IDs of posts that need to be rescanned.
* We have to rescan these on shutdown instead of through the "save_post" hook since that hook is triggered right after a post is updated.
* That in turn can cause subsequent link updatss/deletions during REST API requests to fail because all links are deleted in the callback.
*
* @since 1.1.0
*
* @var array
*/
public $postsToRescan = [];
/**
* Class constructor.
*
* @since 1.0.0
*/
public function __construct() {
$this->data = new Data();
add_action( $this->scanActionName, [ $this, 'scanPosts' ], 11, 1 );
add_action( 'save_post', [ $this, 'scanPost' ], 21, 1 );
add_action( 'shutdown', [ $this, 'rescanPosts' ] );
if ( ! is_admin() ) {
return;
}
add_action( 'init', [ $this, 'scheduleScan' ], 3003 );
}
/**
* Schedules the initial links scan.
*
* @since 1.0.0
*
* @return void
*/
public function scheduleScan() {
// If there is no action at all, schedule one.
if ( ! aioseoBrokenLinkChecker()->actionScheduler->isScheduled( $this->scanActionName ) ) {
aioseoBrokenLinkChecker()->actionScheduler->scheduleAsync( $this->scanActionName );
}
}
/**
* Scans posts for links and stores them in the DB.
*
* @since 1.0.0
*
* @param bool $scheduleNewAction Whether to schedule a new action.
* @return void
*/
public function scanPosts( $scheduleNewAction = true ) {
static $iterations = 0;
$iterations++;
aioseoBrokenLinkChecker()->helpers->timeElapsed();
$postsToScan = $this->data->getPostsToScan();
if ( empty( $postsToScan ) ) {
if ( $scheduleNewAction ) {
aioseoBrokenLinkChecker()->actionScheduler->scheduleSingle( $this->scanActionName, 15 * MINUTE_IN_SECONDS );
}
return;
}
foreach ( $postsToScan as $postToScan ) {
$this->scanPost( $postToScan );
}
$timeElapsed = aioseoBrokenLinkChecker()->helpers->timeElapsed();
if ( 10 > $timeElapsed && 200 > $iterations ) {
// If we still have time, do another scan.
$this->scanPosts();
return;
}
if ( $scheduleNewAction ) {
aioseoBrokenLinkChecker()->actionScheduler->scheduleSingle( $this->scanActionName, MINUTE_IN_SECONDS );
}
}
/**
* Scans the given individual post for links.
*
* @since 1.0.0
*
* @param Object|int $post The post object or ID (if called on "save_post").
* @return void
*/
public function scanPost( $post ) {
if ( doing_action( 'save_post' ) && ! empty( $this->postsToRescan ) ) {
// If posts need to be reindexed manually, bail.
return;
}
if ( ! is_object( $post ) ) {
$post = get_post( $post );
}
// Check if we didn't scan this post in the last 3 seconds. This is to prevent a second, subsequent request from scanning the same post.
if ( aioseoBrokenLinkChecker()->core->cache->get( 'aioseo_blc_scan_post_' . $post->ID ) ) {
return;
}
if ( ! aioseoBrokenLinkChecker()->helpers->isScannablePost( $post ) ) {
return;
}
$this->data->indexLinks( $post->ID );
$aioseoPost = Models\Post::getPost( $post->ID );
$aioseoPost->link_scan_date = gmdate( 'Y-m-d H:i:s' );
$aioseoPost->save();
// Set a transient to prevent scanning the same post again in the next 3 seconds.
aioseoBrokenLinkChecker()->core->cache->update( 'aioseo_blc_scan_post_' . $post->ID, true, 3 );
}
/**
* Reindexes posts on shutdown.
*
* @since 1.1.0
*
* @return void
*/
public function rescanPosts() {
if ( empty( $this->postsToRescan ) ) {
return;
}
foreach ( $this->postsToRescan as $postId ) {
$this->scanPost( $postId );
}
}
} vhosts/uyarreklam.com.tr/httpdocs/wp-content/plugins/all-in-one-seo-pack/app/Common/Meta/Links.php 0000644 00000011442 15155140574 0030546 0 ustar 00 var/www <?php
namespace AIOSEO\Plugin\Common\Meta;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Instantiates the meta links "next" and "prev".
*
* @since 4.0.0
*/
class Links {
/**
* Get the prev/next links for the current page.
*
* @since 4.0.0
*
* @return array An array of link data.
*/
public function getLinks() {
$links = [
'prev' => '',
'next' => '',
];
if ( is_home() || is_archive() || is_paged() ) {
$links = $this->getHomeLinks();
}
if ( is_page() || is_single() ) {
global $post;
$links = $this->getPostLinks( $post );
}
$links['prev'] = apply_filters( 'aioseo_prev_link', $links['prev'] );
$links['next'] = apply_filters( 'aioseo_next_link', $links['next'] );
return $links;
}
/**
* Get the prev/next links for the current page (home/archive, etc.).
*
* @since 4.0.0
*
* @return array An array of link data.
*/
private function getHomeLinks() {
$prev = '';
$next = '';
$page = aioseo()->helpers->getPageNumber();
global $wp_query; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$maxPage = $wp_query->max_num_pages; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
if ( $page > 1 ) {
$prev = get_previous_posts_page_link();
}
if ( $page < $maxPage ) {
$next = get_next_posts_page_link();
$paged = is_paged();
if ( ! is_single() ) {
if ( ! $paged ) {
$page = 1;
}
$nextpage = intval( $page ) + 1;
if ( ! $maxPage || $maxPage >= $nextpage ) {
$next = get_pagenum_link( $nextpage );
}
}
}
// Remove trailing slashes if not set in the permalink structure.
$prev = aioseo()->helpers->maybeRemoveTrailingSlash( $prev );
$next = aioseo()->helpers->maybeRemoveTrailingSlash( $next );
// Remove any query args that may be set on the URL, except if the site is using plain permalinks.
$permalinkStructure = get_option( 'permalink_structure' );
if ( ! empty( $permalinkStructure ) ) {
$prev = explode( '?', $prev )[0];
$next = explode( '?', $next )[0];
}
return [
'prev' => $prev,
'next' => $next,
];
}
/**
* Get the prev/next links for the current post.
*
* @since 4.0.0
*
* @param \WP_Post $post The post.
* @return array An array of link data.
*/
private function getPostLinks( $post ) {
$prev = '';
$next = '';
$numpages = 1;
$page = aioseo()->helpers->getPageNumber();
$content = is_a( $post, 'WP_Post' ) ? $post->post_content : '';
if ( false !== strpos( $content, '<!--nextpage-->', 0 ) ) {
$content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
// Ignore nextpage at the beginning of the content.
if ( 0 === strpos( $content, '<!--nextpage-->', 0 ) ) {
$content = substr( $content, 15 );
}
$pages = explode( '<!--nextpage-->', $content );
$numpages = count( $pages );
} else {
$page = null;
}
if ( ! empty( $page ) ) {
if ( $page > 1 ) {
$prev = $this->getLinkPage( $page - 1 );
}
if ( $page + 1 <= $numpages ) {
$next = $this->getLinkPage( $page + 1 );
}
}
return [
'prev' => $prev,
'next' => $next,
];
}
/**
* This is a clone of _wp_link_page, except that we don't output HTML.
*
* @since 4.0.0
*
* @param integer $number The page number.
* @return string The URL.
*/
private function getLinkPage( $number ) {
global $wp_rewrite; // phpcs:ignore Squiz.NamingConventions.ValidVariableName
$post = get_post();
$queryArgs = [];
if ( 1 === (int) $number ) {
$url = get_permalink();
} else {
if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, [ 'draft', 'pending' ], true ) ) {
$url = add_query_arg( 'page', $number, get_permalink() );
} elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) === $post->ID ) {
$url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $number, 'single_paged' ); // phpcs:ignore Squiz.NamingConventions.ValidVariableName
} else {
$url = trailingslashit( get_permalink() ) . user_trailingslashit( $number, 'single_paged' );
}
}
if ( is_preview() ) {
// phpcs:disable HM.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Recommended
if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
$queryArgs['preview_id'] = sanitize_text_field( wp_unslash( $_GET['preview_id'] ) );
$queryArgs['preview_nonce'] = sanitize_text_field( wp_unslash( $_GET['preview_nonce'] ) );
}
// phpcs:enable
$url = get_preview_post_link( $post, $queryArgs, $url );
}
return esc_url( $url );
}
}