Plugin Directory

Changeset 3412197


Ignore:
Timestamp:
12/05/2025 12:40:50 PM (3 months ago)
Author:
aryans
Message:
  • Feature to remove local media
  • Improved media handling
Location:
media-stream
Files:
21 added
5 edited

Legend:

Unmodified
Added
Removed
  • media-stream/trunk/app/AjaxController.php

    r3391139 r3412197  
    1919            add_action('wp_ajax_mediaStream_upload_missing_video', [$this, 'mediaStream_upload_missing_video_clbk']);
    2020            add_action('wp_ajax_reencode_bunny_video', [$this, 'reencode_bunny_video_clbk']);
     21            add_action('wp_ajax_removelocal_bunny_video', [$this, 'removelocal_bunny_video_clbk']);
    2122            add_action('wp_ajax_mediaStream_get_media_status_ping', [$this, 'mediaStream_get_media_status_ping_clbk']);
    2223        }
     
    139140            exit();
    140141        }
     142       
     143        public function removelocal_bunny_video_clbk(){
     144            $resp = ['status' => 400, 'message' => 'Original file is missing'];
     145
     146            if (isset($_POST['_']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_'])), 'mediaStream_ajax_request')){
     147                $attachment_id = isset($_POST['attachment_id']) ? sanitize_text_field(wp_unslash($_POST['attachment_id'])) : '';
     148                if ($attachment_id != "") {
     149                    $attachment_file = get_attached_file($attachment_id);
     150                    if(file_exists($attachment_file) && unlink($attachment_file)){
     151                        $resp = ['status' => 200, 'message' => 'Removed'];
     152                        update_post_meta(intval($attachment_id), 'mediaStream_local_removed', true);
     153                    }else{
     154                        $resp = ['status' => 400, 'message' => 'Invalid'];
     155                    }
     156                }
     157            }
     158            wp_send_json($resp, $resp['status'], JSON_PRETTY_PRINT);
     159            exit();
     160        }
    141161
    142162        public function mediaStream_save_settings_callback()
  • media-stream/trunk/app/MainController.php

    r3389424 r3412197  
    131131                    }
    132132                    $resp_html .= '<button class="button reencode_bunny_video" data_attch_id="' . $post->ID . '" data_video_id="' . $video_id . '">Re-encode</button>';
     133                    if(get_post_meta(intval($post->ID), 'mediaStream_local_removed', true) != true){
     134                        $resp_html .= '<br><br><button class="button removelocal_bunny_video" data_attch_id="' . $post->ID . '" data_video_id="' . $video_id . '" style="color: #d63638;border-color: #d63638;">Remove Local copy</button>';
     135                    }
    133136                }
    134137
  • media-stream/trunk/assets/js/script.js

    r3399591 r3412197  
    186186        });
    187187    });
     188   
     189    jQuery(document).on('click', '.removelocal_bunny_video', function () {
     190        const this_btn = jQuery(this);
     191        const video_id = this_btn.attr('data_video_id');
     192        const this_id = this_btn.attr('data_attch_id');
     193        this_btn.text('Please wait...').attr('disabled', 'disabled');
     194        jQuery.ajax({
     195            url: ajaxurl,
     196            type: "POST",
     197            data: {
     198                action: 'removelocal_bunny_video',
     199                video_id: video_id,
     200                attachment_id: this_id,
     201                _: mediaStream_var.nonce
     202            },
     203        }).done((res) => {
     204            console.log(res);
     205            if (res.status == 200) {
     206//              this_btn.remove();
     207                location.reload();
     208            }
     209        }).fail((err) => {
     210            console.log(err);
     211        });
     212    });
    188213
    189214
     
    267292});
    268293
    269 jQuery(document).ready(function() {
    270     setTimeout(function(){
    271         window.cstm_call_all_scrip();
    272     }, 1000);
    273 });
     294// jQuery(document).ready(function() {
     295// setTimeout(function(){
     296//      window.cstm_call_all_scrip();
     297// }, 1000);
     298// });
  • media-stream/trunk/media-stream.php

    r3399591 r3412197  
    66 * Author: Blurr Studio
    77 * Author URI: https://blurr.it/
    8  * Version: 1.0.8
     8 * Version: 1.0.9
    99 * License: GPL v2 or later
    1010 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
  • media-stream/trunk/readme.txt

    r3399591 r3412197  
    44Tested up to:      6.8
    55Requires PHP:      7.2
    6 Stable tag:        1.0.8
     6Stable tag:        1.0.9
    77License:           GPLv2 or later
    88Contributors:      aryans
     
    6060== Changelog ==
    6161
     62= 1.0.9 =
     63* Feature to remove local media
     64* Improved media handling
     65
    6266= 1.0.8 =
    6367* Optimized loading time
Note: See TracChangeset for help on using the changeset viewer.