Deprecated

This function has been deprecated.

ap_upload_js_init()

Description #

Initialize AnsPress uploader settings.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: includes/deprecated.php

94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
function ap_upload_js_init() {
    _deprecated_function( __FUNCTION__, '4.1.0' );
 
    if ( ap_user_can_upload() ) {
        $mimes = [];
 
        foreach ( ap_allowed_mimes() as $ext => $mime ) {
            $mimes[] = [
                'title'      => $mime,
                'extensions' => str_replace( '|', ',', $ext ),
            ];
        }
 
        $plupload_init = array(
            'runtimes'            => 'html5,flash,silverlight,html4',
            'browse_button'       => 'plupload-browse-button',
            'container'           => 'plupload-upload-ui',
            'drop_element'        => 'ap-drop-area',
            'file_data_name'      => 'async-upload',
            'url'                 => admin_url( 'admin-ajax.php' ),
            'flash_swf_url'       => includes_url( 'js/plupload/plupload.flash.swf' ),
            'silverlight_xap_url' => includes_url( 'js/plupload/plupload.silverlight.xap' ),
            'filters'             => array(
                'mime_types'         => $mimes,
                'max_file_size'      => (int) ap_opt( 'max_upload_size' ) . 'b',
                'prevent_duplicates' => true,
            ),
            // 'maxfiles'            => ap_opt( 'uploads_per_post' ),
            'multipart_params'    => [
                '_wpnonce' => wp_create_nonce( 'media-upload' ),
                'action'   => 'ap_image_submission',
            ],
        );
 
        echo '<script type="text/javascript"> wpUploaderInit =' . wp_json_encode( $plupload_init ) . ';</script>';
        echo '<script type="text/html" id="ap-upload-template">
                <span class="apicon-check"> ' . esc_attr__( 'Uploaded', 'anspress-question-answer' ) . '</span>
                <span class="apicon-stop"> ' . esc_attr__( 'Failed', 'anspress-question-answer' ) . '</span>
                <span class="ap-upload-name"></span>
                <a href="#" class="insert-to-post">' . esc_attr__( 'Insert to post', 'anspress-question-answer' ) . '</a>
                <a href="#" class="apicon-trashcan"></a>
                <div class="ap-progress"></div>
        </script>';
    }
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment