コード例 #1
0
function layerslider_convert()
{
    // Get old sliders if any
    $sliders = get_option('layerslider-slides', array());
    $sliders = is_array($sliders) ? $sliders : unserialize($sliders);
    // Create new storage in DB
    layerslider_create_db_table();
    // Iterate over them
    if (!empty($sliders) && is_array($sliders)) {
        foreach ($sliders as $key => $slider) {
            LS_Sliders::add($slider['properties']['title'], $slider);
        }
    }
    // Remove old data and exit
    delete_option('layerslider-slides');
    header('Location: admin.php?page=layerslider');
    die;
}
コード例 #2
0
ファイル: actions.php プロジェクト: ftopolovec/proart
function layerslider_duplicateslider()
{
    // Check and get the ID
    $id = (int) $_GET['id'];
    if (!isset($_GET['id'])) {
        return;
    }
    // Get the original slider
    $slider = LS_Sliders::find((int) $_GET['id']);
    $data = $slider['data'];
    // Name check
    if (empty($data['properties']['title'])) {
        $data['properties']['title'] = 'Unnamed';
    }
    // Insert the duplicate
    $data['properties']['title'] .= ' copy';
    LS_Sliders::add($data['properties']['title'], $data);
    // Success
    header('Location: admin.php?page=layerslider');
    die;
}
コード例 #3
0
 public function addSlider($file)
 {
     // Get slider data and title
     $data = json_decode(file_get_contents($file), true);
     $title = $data['properties']['title'];
     // Slider settings
     if (!empty($data['properties']['backgroundimage'])) {
         $data['properties']['backgroundimage'] = $this->attachURLForImage($data['properties']['backgroundimage']);
     }
     if (!empty($data['properties']['yourlogo'])) {
         $data['properties']['yourlogoId'] = '';
         $data['properties']['yourlogo'] = $this->attachURLForImage($data['properties']['yourlogo']);
     }
     // Slides
     if (!empty($data['layers']) && is_array($data['layers'])) {
         foreach ($data['layers'] as &$slide) {
             if (!empty($slide['properties']['background'])) {
                 $slide['properties']['backgroundId'] = '';
                 $slide['properties']['background'] = $this->attachURLForImage($slide['properties']['background']);
             }
             if (!empty($slide['properties']['thumbnail'])) {
                 $slide['properties']['thumbnailId'] = '';
                 $slide['properties']['thumbnail'] = $this->attachURLForImage($slide['properties']['thumbnail']);
             }
             // Layers
             if (!empty($slide['sublayers']) && is_array($slide['sublayers'])) {
                 foreach ($slide['sublayers'] as &$layer) {
                     if (!empty($layer['image'])) {
                         $layer['imageId'] = '';
                         $layer['image'] = $this->attachURLForImage($layer['image']);
                     }
                 }
             }
         }
     }
     // Add slider
     LS_Sliders::add($title, $data);
 }
コード例 #4
0
ファイル: actions.php プロジェクト: IDOAgency/PAHClinic
function ls_sliders_bulk_action()
{
    // Remove
    if ($_POST['action'] === 'remove') {
        if (!empty($_POST['sliders']) && is_array($_POST['sliders'])) {
            foreach ($_POST['sliders'] as $item) {
                LS_Sliders::remove(intval($item));
            }
            header('Location: admin.php?page=layerslider&message=removeSuccess');
            die;
        } else {
            header('Location: admin.php?page=layerslider&message=removeSelectError&error=1');
            die;
        }
    }
    // Delete
    if ($_POST['action'] === 'delete') {
        if (!empty($_POST['sliders']) && is_array($_POST['sliders'])) {
            foreach ($_POST['sliders'] as $item) {
                LS_Sliders::delete(intval($item));
            }
            header('Location: admin.php?page=layerslider&message=deleteSuccess');
            die;
        } else {
            header('Location: admin.php?page=layerslider&message=deleteSelectError&error=1');
            die;
        }
    }
    // Restore
    if ($_POST['action'] === 'restore') {
        if (!empty($_POST['sliders']) && is_array($_POST['sliders'])) {
            foreach ($_POST['sliders'] as $item) {
                LS_Sliders::restore(intval($item));
            }
            header('Location: admin.php?page=layerslider&message=restoreSuccess');
            die;
        } else {
            header('Location: admin.php?page=layerslider&message=restoreSelectError&error=1');
            die;
        }
    }
    // Merge
    if ($_POST['action'] === 'merge') {
        // Error check
        if (!isset($_POST['sliders'][1]) || !is_array($_POST['sliders'])) {
            header('Location: admin.php?page=layerslider&error=1&message=mergeSelectError');
            die;
        }
        if ($sliders = LS_Sliders::find($_POST['sliders'])) {
            foreach ($sliders as $key => $item) {
                // Get IDs
                $ids[] = '#' . $item['id'];
                // Merge slides
                if ($key === 0) {
                    $data = $item['data'];
                } else {
                    $data['layers'] = array_merge($data['layers'], $item['data']['layers']);
                }
            }
            // Save as new
            $name = 'Merged sliders of ' . implode(', ', $ids);
            $data['properties']['title'] = $name;
            LS_Sliders::add($name, $data);
        }
        header('Location: admin.php?page=layerslider&message=mergeSuccess');
        die;
    }
}
コード例 #5
0
ファイル: actions.php プロジェクト: scottnkerr/eeco
function ls_add_new_slider()
{
    $id = LS_Sliders::add($_POST['title']);
    header('Location: admin.php?page=layerslider&action=edit&id=' . $id . '&showsettings=1');
    die;
}