Plugin Directory

Changeset 1430794


Ignore:
Timestamp:
06/05/2016 10:39:29 AM (10 years ago)
Author:
nikdo
Message:

Pass webcam directory as argument

Location:
react-webcam/tags/1.2.0
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • react-webcam/tags/1.2.0/react-webcam.php

    r1241407 r1430794  
    2323    wp_enqueue_script('ReactWebcam_ActualImage', plugins_url('js/ActualImage.js', __FILE__), array('react'));
    2424
    25     $upload_dir = wp_upload_dir();
     25    $upload_path = wp_upload_dir();
    2626
    2727    $ajax_url = admin_url('admin-ajax.php');
    28     $webcam_url = $upload_dir['baseurl'] . '/' . WEBCAM_DIR . '/';
    29     $initial_image_url = $webcam_url . '/' . get_last_filename();
     28    $webcam_url = $upload_path['baseurl'] . '/' . WEBCAM_DIR . '/';
     29    $initial_image_url = $webcam_url . '/' . get_last_filename(WEBCAM_DIR);
    3030
    3131    return '
     
    4747
    4848// Returns filename of the last webcam image.
    49 function get_last_filename() {
     49function get_last_filename($webcam_dir) {
    5050
    51     $filenames = get_filenames();
     51    $filenames = get_filenames($webcam_dir);
    5252
    5353    $last_filename = end($filenames);
     
    5959
    6060// Returns list of all webcam image filenames.
    61 function get_filenames() {
     61function get_filenames($webcam_dir) {
    6262
    63     $upload_dir = wp_upload_dir();
    64     $webcam_dir = $upload_dir['basedir'] . '/' . WEBCAM_DIR . '/';
     63    $upload_path = wp_upload_dir();
     64    $webcam_path = $upload_path['basedir'] . '/' . $webcam_dir . '/';
    6565
    6666    $filenames = array();
    67     foreach (glob($webcam_dir . '*') as $path) {
     67    foreach (glob($webcam_path . '*') as $path) {
    6868        array_push($filenames, basename($path));
    6969    }
     
    7575// AJAX call handler to return last webcam image filename.
    7676function last_image() {
    77     echo get_last_filename();
     77    echo get_last_filename(WEBCAM_DIR);
    7878    wp_die();
    7979}
Note: See TracChangeset for help on using the changeset viewer.