HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, 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
Upload Files
File: /home/u547966/brikov.ru/www/wp-content/plugins/wp-media-folder/class/wpmf-background-folder.php
<?php

class Wpmf_Background_Folder{
    
    function __construct() {
        add_action( 'admin_enqueue_scripts', array($this, 'wpmf_load_custom_wp_admin_script') );
        add_filter("attachment_fields_to_edit", array($this, "wpmf_attachment_fields_to_edit"), 10, 2);
        add_filter("attachment_fields_to_save", array($this, "wpmf_attachment_fields_to_save"), 10, 2);
        add_action('wp_ajax_wpmf_get_option_bg', array($this,'wpmf_get_option_bg'));
    }
    
    public function wpmf_load_custom_wp_admin_script() {
        global $pagenow,$current_screen;
        if($current_screen->base != 'settings_page_option-folder' && $pagenow != 'media-new.php'){
            wp_register_script('wpmf-bg_folder', plugins_url( '/assets/js/wpmf-background-folder.js', dirname(__FILE__) ),array('plupload'),WPMF_VERSION);
            wp_enqueue_script('wpmf-bg_folder');
        }
    }
    
    
    function wpmf_attachment_fields_to_edit($form_fields, $post) {
        global $pagenow;
        if($pagenow != 'post.php'){
            $current_folder = get_the_terms($post, 'wpmf-category');
            if(!empty($current_folder) && substr($post->post_mime_type, 0, 5) == 'image'){
                $option_bgfolder = get_option('wpmf_field_bgfolder');
                $form_fields['wpmf_field_bgfolder'] = array(
                    "label" => __('Folder cover','wpmf'),
                    "input" => "html",
                    'html'  => '<input type="checkbox" class="wpmf_field_bgfolder" id="attachments-'.$post->ID.'-wpmf_field_bgfolder" name="attachments['.$post->ID.'][wpmf_field_bgfolder]">'
                );
            }
        }
        
        return $form_fields;
    }
    
    function wpmf_attachment_fields_to_save($post, $attachment) {
        $option_bgfolder = get_option('wpmf_field_bgfolder');
        if(empty($option_bgfolder)){
            $option_bgfolder = array();
        }
        
        if (isset($attachment['wpmf_field_bgfolder']) && $attachment['wpmf_field_bgfolder'] == 'on') {
            $image_thumb = wp_get_attachment_image_src($post['ID'], 'thumbnail' );
            $option_bgfolder[$_SESSION['wpmf-current-folder']] = array($post['ID'],$image_thumb[0]);
        }else{
            unset($option_bgfolder[$_SESSION['wpmf-current-folder']]);
        }
        
	update_option('wpmf_field_bgfolder', $option_bgfolder);	
        return $post;
    }
    
    function wpmf_get_option_bg(){
        $option_bgfolder = get_option('wpmf_field_bgfolder');
        if(!empty($option_bgfolder) && !empty($option_bgfolder[$_SESSION['wpmf-current-folder']])){
            wp_send_json($option_bgfolder[$_SESSION['wpmf-current-folder']][0]);
        }else{
            wp_send_json(false);
        }
    }
}
?>