| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/polylang/modules/sync/ |
Upload File : |
<?php
/**
* A class to manage copy and synchronization of post metas
*
* @since 2.3
*/
class PLL_Sync_Post_Metas extends PLL_Sync_Metas {
public $options;
/**
* Constructor
*
* @since 2.3
*
* @param object $polylang
*/
public function __construct( &$polylang ) {
$this->meta_type = 'post';
parent::__construct( $polylang );
$this->options = &$polylang->options;
add_filter( 'pll_translate_post_meta', array( $this, 'translate_thumbnail_id' ), 10, 3 );
}
/**
* Get the custom fields to copy or synchronize
*
* @since 2.3
*
* @param int $from Id of the post from which we copy informations
* @param int $to Id of the post to which we paste informations
* @param string $lang Language slug
* @param bool $sync True if it is synchronization, false if it is a copy
* @return array List of meta keys
*/
protected function get_metas_to_copy( $from, $to, $lang, $sync = false ) {
// Copy or synchronize post metas and allow plugins to do the same
$metas = get_post_custom( $from );
$keys = array();
// Get public meta keys ( including from translated post in case we just deleted a custom field )
if ( ! $sync || in_array( 'post_meta', $this->options['sync'] ) ) {
foreach ( $keys = array_unique( array_merge( array_keys( $metas ), array_keys( get_post_custom( $to ) ) ) ) as $k => $meta_key ) {
if ( is_protected_meta( $meta_key ) ) {
unset( $keys[ $k ] );
}
}
}
// Add page template and featured image
foreach ( array( '_wp_page_template', '_thumbnail_id' ) as $meta ) {
if ( ! $sync || in_array( $meta, $this->options['sync'] ) ) {
$keys[] = $meta;
}
}
// Random header image
if ( $this->options['media_support'] ) {
$keys[] = '_wp_attachment_is_custom_header';
}
/** This filter is documented in modules/sync/sync-metas.php */
return array_unique( apply_filters( 'pll_copy_post_metas', $keys, $sync, $from, $to, $lang ) );
}
/**
* Translates the thumbnail id
*
* @since 2.3
*
* @param int $value Thumbnail id
* @param string $key Meta key
* @param string $lang Language code
* @return int
*/
public function translate_thumbnail_id( $value, $key, $lang ) {
return ( $this->options['media_support'] && '_thumbnail_id' === $key && $to_value = $this->model->post->get_translation( $value, $lang ) ) ? $to_value : $value;
}
}