Plugin Directory

Changeset 1142769


Ignore:
Timestamp:
04/23/2015 01:37:57 AM (11 years ago)
Author:
1eftHander
Message:

1.1.0

  • 포스트별 이미지 다운로드 기능 추가 (Cathy Paik님 아이디어 감사합니다.)
Location:
image-export/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • image-export/trunk/download.php

    r1112569 r1142769  
    44
    55    header( 'Content-Type: application/zip' );
    6     header( 'Content-Disposition: attachment; filename="images.zip"' );
     6    header( 'Content-Disposition: attachment; filename="' . $file . '"' );
    77    readfile( $file );
    88    unlink( $file );
  • image-export/trunk/image-export.js

    r1112569 r1142769  
    11(function($) {
    22    $(document).ready(function() {
    3         $('#post-query-submit').parent('div').append('<button type="button" id="ie-excute" class="button button-primary">' + message.m001 + '</button>');
    4        
    53        $('#ie-excute').click(function() {
    64            var checked = $('#the-list input[type=checkbox]:checked');
     
    1816            var params = {
    1917                action : 'ie_execute',
     18                mode   : 'upload',
    2019                id     : valArr.join(',')
    2120            };
     
    3433            );
    3534        });
     35       
     36        $('.ie-export-post').click(function() {
     37            var params = {
     38                action : 'ie_execute',
     39                mode   : 'post',
     40                id     : $(this).attr("data-id")
     41            };
     42           
     43            $.post(
     44                obj.link,
     45                params,
     46                function(data){
     47                    var ret_obj = $.parseJSON(data);
     48                    $('#wpbody-content .wrap').prepend(ret_obj.msg);
     49                   
     50                    if (ret_obj.url != '') {
     51                        window.location = ret_obj.url;
     52                    }
     53                }
     54            );
     55        });
    3656    });
    3757})(jQuery);
  • image-export/trunk/image-export.php

    r1112569 r1142769  
    44Plugin URI: http://www.1efthander.com/category/wordpress-plugins/image-export
    55Description: Image Export 플러그인은 관리자가 업로드한 이미지를 선택적으로 다운로드할 수 있도록 도와줍니다.
    6 Version: 1.0.0
     6Version: 1.1.0
    77Author: 1eftHander
    88Author URI: http://www.1efthander.com
    99*/
    1010
    11 define( 'IMAGE_EXPORT_VERSION', '1.0.0' );
     11define( 'IMAGE_EXPORT_VERSION', '1.1.0' );
    1212define( 'DOWNLOAD_PATH', dirname( __FILE__ ) );
    13 define( 'DOWNLOAD_FILE_NAME', 'images.zip' );
    1413
    1514/**
    1615 * 관리자페이지 Javascript 추가
     16 * version: 1.0.0
     17 * Date: 2015-03-14
    1718 */
    1819function ie_enqueue_scripts() {
    1920    global $current_screen;
    20     if ( 'upload' != $current_screen->id ) return false;
    2121   
    22     wp_register_script( 'image_export', plugins_url( 'image-export-min.js', __FILE__ ), false, IMAGE_EXPORT_VERSION );
    23     wp_enqueue_script( 'image_export' );
     22    switch ( $current_screen->id ) {
     23        case 'upload':
     24            wp_register_script( 'image_export_button', plugins_url( 'image-export-button.js', __FILE__ ), false, IMAGE_EXPORT_VERSION );
     25            wp_register_script( 'image_export', plugins_url( 'image-export.js', __FILE__ ), false, IMAGE_EXPORT_VERSION );
     26           
     27            wp_enqueue_script( 'image_export_button' );
     28            wp_enqueue_script( 'image_export' );
     29            break;
     30        default :
     31            wp_register_script( 'image_export', plugins_url( 'image-export.js', __FILE__ ), false, IMAGE_EXPORT_VERSION );
     32            wp_enqueue_script( 'image_export' );
     33            break;
     34    }
     35   
    2436    $textdomains = array(
    2537        'm001' => __( 'Image Export', 'image-export' ),
     
    3446/**
    3547 * 이미지 다운로드 처리
     48 * version 1.0.0
     49 * Date 2015-03-14
    3650 */
    3751function file_size_format( $file_size ) {
     
    6579   
    6680    $id = $_POST['id'];
    67     $temps = explode( ',', $id );
     81    $mode = $_POST['mode'];
    6882   
    69     foreach ( $temps as $temp ) {
    70         $ids[] = intval( $temp );
     83    switch ( $mode ) {
     84        case 'upload':
     85            $temps = explode( ',', $id );
     86            foreach ( $temps as $temp ) {
     87                $ids[] = intval( $temp );
     88            }
     89           
     90            $args = array(
     91                'posts_per_page' => -1,
     92                'include'        => $ids,
     93                'post_type'      => 'attachment',
     94                'post_status'    => 'inherit'
     95            );
     96           
     97            $download_file_name = 'images.zip';
     98            break;
     99        default :
     100            $args = array(
     101                'posts_per_page' => -1,
     102                'post_parent'    => $id,
     103                'post_type'      => 'attachment',
     104                'post_status'    => 'inherit'
     105            );
     106            $download_file_name = 'images_' . $id . '.zip';
     107            break;
    71108    }
    72    
    73     $args = array(
    74         'posts_per_page' => -1,
    75         'include'        => $ids,
    76         'post_type'      => 'attachment',
    77         'post_status'    => 'inherit'
    78     );
    79109   
    80110    $posts = get_posts( $args );
     
    85115   
    86116    require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
    87     $zip_file = new PclZip( DOWNLOAD_PATH . '/' . DOWNLOAD_FILE_NAME );
     117    $zip_file = new PclZip( DOWNLOAD_PATH . '/' . $download_file_name );
    88118    $archive = $zip_file->create( $lists, PCLZIP_OPT_REMOVE_ALL_PATH );
    89     $file_size = file_size_format( filesize( DOWNLOAD_PATH . '/' . DOWNLOAD_FILE_NAME ) );
     119    $file_size = file_size_format( filesize( DOWNLOAD_PATH . '/' . $download_file_name ) );
    90120   
    91     if ( !empty( $archive ) ) {
    92         $rets['url'] = plugins_url( 'download.php', __FILE__ ) . '?file=' . DOWNLOAD_FILE_NAME;
    93         $rets['msg'] = '<div class="updated"><p><strong>' . sprintf( __( 'Image.zip file has been downloaded. Export file size : %s', 'image-export' ) . '</strong></p></div>', $file_size );
     121    if ( $posts ) {
     122        if ( !empty( $archive ) ) {
     123            $rets['url'] = plugins_url( 'download.php', __FILE__ ) . '?file=' . $download_file_name;
     124            $rets['msg'] = '<div class="updated"><p><strong>' . sprintf( __( 'Images.zip file has been downloaded. Export file size : %s', 'image-export' ) . '</strong></p></div>', $file_size );
     125        } else {
     126            $rets['msg'] = '<div class="error"><p><strong>' . __( 'Failed to create images.zip. Please contact the developer.', 'image-export' ) . '</strong></p></div>';
     127        }
    94128    } else {
    95         $rets['msg'] = '<div class="error"><p><strong>' . __( 'Failed to create images.zip. Please contact the developer.', 'image-export' ) . '</strong></p></div>';
     129        $rets['msg'] = '<div class="error"><p><strong>' . __( 'This post, there is no image.', 'image-export' ) . '</strong></p></div>';
    96130    }
    97131   
     
    104138/**
    105139 * 다국어 설정
     140 * version 1.0.0
     141 * Date 2015-03-14
    106142 */
    107143function ie_textdomain() {
     
    109145}
    110146add_action( 'admin_init', 'ie_textdomain' );
     147
     148
     149/**
     150 * 포스트별 이미지 다운로드 링크 추가
     151 */
     152function ie_post_row_actions( $actions, $post ) {
     153    $actions['export'] = '<a href="#" class="ie-export-post" data-id="' . $post->ID . '">' . __( 'Image Export', 'image-export' ) . '</a>';
     154   
     155    return $actions;
     156}
     157add_filter('post_row_actions', 'ie_post_row_actions', 10, 2);
    111158?>
  • image-export/trunk/languages/image-export-ko_KR.po

    r1112569 r1142769  
    44"Report-Msgid-Bugs-To: \n"
    55"POT-Creation-Date: Sat Mar 14 2015 01:01:56 GMT+0900 (대한민국 표준시)\n"
    6 "PO-Revision-Date: Sat Mar 14 2015 01:10:55 GMT+0900 (대한민국 표준시)\n"
     6"PO-Revision-Date: Thu Apr 23 2015 10:05:19 GMT+0900 (대한민국 표준시)\n"
    77"Last-Translator: mbr <lh.jhkim+mbr@gmail.com>\n"
    88"Language-Team: \n"
     
    2323"X-Loco-Target-Locale: ko_KR"
    2424
    25 #: ../image-export.php:25
     25#: ../image-export.php:37 ../image-export.php:153
    2626msgid "Image Export"
    2727msgstr "이미지 다운로드"
    2828
    29 #: ../image-export.php:26
     29#: ../image-export.php:38
    3030msgid "Please select the image you want to download."
    3131msgstr "다운로드할 이미지를 선택하십시오."
    3232
    33 #: ../image-export.php:93
     33#: ../image-export.php:124
    3434#, php-format
    35 msgid "Image.zip file has been downloaded. Export file size : %s"
    36 msgstr "Images.zip 파일이 다운로드 되었습니다. 다운로드 파일 크기 : %s"
     35msgid "Images.zip file has been downloaded. Export file size : %s"
     36msgstr "Images.zip 파일 다운로드 완료. 파일 크기 : %s"
    3737
    38 #: ../image-export.php:95
     38#: ../image-export.php:126
    3939msgid "Failed to create images.zip. Please contact the developer."
    4040msgstr "Images.zip 압축 실패. 개발자에게 문의하십시오."
     41
     42#: ../image-export.php:129
     43msgid "This post, there is no image."
     44msgstr "이 글에는 이미지가 없습니다."
  • image-export/trunk/languages/image-export.pot

    r1112569 r1142769  
    66"Report-Msgid-Bugs-To: \n"
    77"POT-Creation-Date: Sat Mar 14 2015 01:01:56 GMT+0900 (대한민국 표준시)\n"
    8 "POT-Revision-Date: Sat Mar 14 2015 01:09:43 GMT+0900 (대한민국 표준시)\n"
     8"POT-Revision-Date: Thu Apr 23 2015 10:02:39 GMT+0900 (대한민국 표준시)\n"
    99"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1010"Last-Translator: \n"
     
    2525"X-Generator: Loco - https://localise.biz/"
    2626
    27 #: ../image-export.php:25
     27#: ../image-export.php:37 ../image-export.php:153
    2828msgid "Image Export"
    2929msgstr ""
    3030
    31 #: ../image-export.php:26
     31#: ../image-export.php:38
    3232msgid "Please select the image you want to download."
    3333msgstr ""
    3434
    35 #: ../image-export.php:93
     35#: ../image-export.php:124
    3636#, php-format
    37 msgid "Image.zip file has been downloaded. Export file size : %s"
     37msgid "Images.zip file has been downloaded. Export file size : %s"
    3838msgstr ""
    3939
    40 #: ../image-export.php:95
     40#: ../image-export.php:126
    4141msgid "Failed to create images.zip. Please contact the developer."
    4242msgstr ""
     43
     44#: ../image-export.php:129
     45msgid "This post, there is no image."
     46msgstr ""
  • image-export/trunk/readme.txt

    r1112569 r1142769  
    22221. 미디어 메뉴 버튼 추가
    23232. 다운로드
     243. 포스트별 이미지 다운로드 링크 추가
    2425
    2526== Changelog ==
    2627
     28= 1.1.0 =
     29* 포스트별 이미지 다운로드 기능 추가 (Cathy Paik님 아이디어 감사합니다.)
     30
    2731= 1.0.0 =
    2832* 배포 시작
Note: See TracChangeset for help on using the changeset viewer.