| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/././public_html/wp-content/plugins/polylang/modules/sync/ |
Upload File : |
<?php
/**
* @package Polylang
*/
/**
* A class to manage copy and synchronization of post metas.
*
* @since 2.3
*/
class PLL_Sync_Post_Metas extends PLL_Sync_Metas {
/**
* Stores the plugin options.
*
* @var array
*/
public $options;
/**
* Constructor.
*
* @since 2.3
*
* @param object $polylang The Polylang object.
*/
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 information.
* @param int $to Id of the post to which we paste information.
* @param string $lang Language slug.
* @param bool $sync True if it is synchronization, false if it is a copy.
* @return string[] List of meta keys.
*/
protected function get_metas_to_copy( $from, $to, $lang, $sync = false ) {
$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'] ) ) {
$from_keys = (array) get_post_custom_keys( $from );
$to_keys = (array) get_post_custom_keys( $to );
$keys = array_unique( array_merge( $from_keys, $to_keys ) );
foreach ( $keys 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;
}
}
if ( $this->options['media_support'] ) {
$keys[] = '_wp_attached_file';
$keys[] = '_wp_attachment_metadata';
$keys[] = '_wp_attachment_backup_sizes';
$keys[] = '_wp_attachment_is_custom_header'; // Random header image.
}
/** 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;
}
}