| 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/./././www/wp-content/plugins/polylang/integrations/wp-offload-media/ |
Upload File : |
<?php
/**
* @package Polylang
*/
/**
* A class to manage the integration with WP Offload Media Lite.
* Version tested: 2.1.1
*
* @since 2.6
*/
class PLL_AS3CF {
/**
* Stores if a media is translated when it is deleted.
*
* @var bool[]
*/
private $is_media_translated = array();
/**
* Initializes filters and actions.
*
* @since 2.6
*/
public function init() {
add_filter( 'pll_copy_post_metas', array( $this, 'copy_post_metas' ) );
add_action( 'delete_attachment', array( $this, 'check_translated_media' ), 5 ); // Before Polylang deletes the translations information.
add_action( 'delete_attachment', array( $this, 'prevent_file_deletion' ), 15 ); // Between Polylang and WP Offload Media.
}
/**
* Synchronizes post metas
*
* @since 2.6
*
* @param array $metas List of custom fields names.
* @return array
*/
public function copy_post_metas( $metas ) {
$metas[] = 'amazonS3_info';
$metas[] = 'as3cf_filesize_total';
return $metas;
}
/**
* Checks if the deleted attachment was translated and stores the information.
*
* @since 2.6
*
* @param int $post_id Id of the attachment being deleted.
*/
public function check_translated_media( $post_id ) {
$this->is_media_translated[ $post_id ] = ( count( pll_get_post_translations( $post_id ) ) > 1 );
}
/**
* Deletes the WP Offload Media information from the attachment being deleted.
* That way WP Offload Media won't delete the file stored in the cloud.
* Done after Polylang has deleted the translations information, to avoid the synchronization of the deletion
* and of course before WP Offload Media deletes the file, normally at priority 20.
*
* @since 2.6
*
* @param int $post_id Id of the attachment being deleted.
*/
public function prevent_file_deletion( $post_id ) {
if ( ! empty( $this->is_media_translated[ $post_id ] ) ) {
delete_post_meta( $post_id, 'amazonS3_info' );
delete_post_meta( $post_id, 'as3cf_filesize_total' );
}
}
}