| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/wordpress-seo/admin/links/ |
Upload File : |
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Links
*/
/**
* Represents the conversion from array with string links into WPSEO_Link objects.
*/
class WPSEO_Link_Factory {
/**
* Represents the classifier for a link. Determines of a link is an outbound or internal one.
*
* @var WPSEO_Link_Type_Classifier
*/
protected $classifier;
/**
* Represents the internal link lookup. This class tries get the postid for a given internal link.
*
* @var WPSEO_Link_Internal_Lookup
*/
protected $internal_lookup;
/**
* Represents the filter for filtering links.
*
* @var WPSEO_Link_Filter
*/
protected $filter;
/**
* Sets the dependencies for this object.
*
* @param WPSEO_Link_Type_Classifier $classifier The classifier to use.
* @param WPSEO_Link_Internal_Lookup $internal_lookup The internal lookup to use.
* @param WPSEO_Link_Filter $filter The link filter.
*/
public function __construct( WPSEO_Link_Type_Classifier $classifier, WPSEO_Link_Internal_Lookup $internal_lookup, WPSEO_Link_Filter $filter ) {
$this->classifier = $classifier;
$this->internal_lookup = $internal_lookup;
$this->filter = $filter;
}
/**
* Formats an array of links to WPSEO_Link object.
*
* @param array $extracted_links The links for format.
*
* @return WPSEO_Link[] The formatted links.
*/
public function build( array $extracted_links ) {
$extracted_links = array_map( array( $this, 'build_link' ), $extracted_links );
$filtered_links = array_filter(
$extracted_links,
array( $this->filter, 'internal_link_with_fragment_filter' )
);
return $filtered_links;
}
/**
* Builds the link.
*
* @param string $link The link to build.
*
* @return WPSEO_Link The built link.
*/
public function build_link( $link ) {
$link_type = $this->classifier->classify( $link );
$target_post_id = 0;
if ( $link_type === WPSEO_Link::TYPE_INTERNAL ) {
$target_post_id = $this->internal_lookup->lookup( $link );
}
return self::get_link( $link, $target_post_id, $link_type );
}
/**
* Returns the link object.
*
* @param string $url The URL of the link.
* @param int $target_post_id The target post ID.
* @param string $type The link type.
*
* @return WPSEO_Link Generated link object.
*/
public static function get_link( $url, $target_post_id, $type ) {
return new WPSEO_Link( $url, $target_post_id, $type );
}
}