| 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/src/repositories/ |
Upload File : |
<?php
/**
* Yoast extension of the Model class.
*
* @package Yoast\YoastSEO\ORM\Repositories
*/
namespace Yoast\WP\Free\Repositories;
use Yoast\WP\Free\ORM\ORMWrapper;
use Yoast\WP\Free\ORM\Yoast_Model;
/**
* Class Primary_Term_Repository
*
* @package Yoast\WP\Free\ORM\Repositories
*/
class Primary_Term_Repository extends ORMWrapper {
/**
* Returns the instance of this class constructed through the ORM Wrapper.
*
* @return \Yoast\WP\Free\Repositories\Primary_Term_Repository
*/
public static function get_instance() {
ORMWrapper::$repositories[ Yoast_Model::get_table_name( 'Primary_Term' ) ] = self::class;
return Yoast_Model::of_type( 'Primary_Term' );
}
/**
* Retrieves an indexable by a post ID and taxonomy.
*
* @param int $post_id The post the indexable is based upon.
* @param string $taxonomy The taxonomy the indexable belongs to.
* @param bool $auto_create Optional. Creates an indexable if it does not exist yet.
*
* @return bool|\Yoast\WP\Free\Models\Indexable Instance of indexable.
*/
public function find_by_postid_and_taxonomy( $post_id, $taxonomy, $auto_create = true ) {
/** @var \Yoast\WP\Free\Models\Primary_Term $primary_term */
$primary_term = $this->where( 'post_id', $post_id )
->where( 'taxonomy', $taxonomy )
->find_one();
if ( $auto_create && ! $primary_term ) {
$primary_term = $this->create();
}
return $primary_term;
}
}