コード例 #1
0
 /**
  * Adds an exported ZIP to the list of importable sample sliders.
  * 
  * @since 5.3.0
  * @access public
  * @param string $path Path to the .zip file
  * @return void
  */
 public static function addDemoSlider($path)
 {
     $slidersPath = $sliders = array();
     $path = rtrim($path, '/\\');
     // It's a direct slider folder
     if (file_exists($path . '/slider.zip')) {
         $slidersPath = array($path);
     } else {
         // Get all children if it's a parent directory
         $slidersPath = glob($path . '/*', GLOB_ONLYDIR);
     }
     // Iterate over the sliders
     foreach ($slidersPath as $key => $path) {
         // Exclude non-valid demo sliders
         if (!file_exists($path . '/slider.zip')) {
             continue;
         }
         // Gather slider data
         $handle = strtolower(basename($path));
         $sliders[$handle] = array('name' => $handle, 'handle' => $handle, 'dir' => $path, 'file' => $path . DIRECTORY_SEPARATOR . 'slider.zip');
         // Get skin info (if any)
         if (file_exists($path . '/info.json')) {
             $sliders[$handle]['info'] = json_decode(file_get_contents($path . '/info.json'), true);
             $sliders[$handle]['name'] = $sliders[$handle]['info']['name'];
         }
         // Get preview (if any)
         if (file_exists($path . '/preview.png')) {
             $url = content_url() . str_replace(realpath(WP_CONTENT_DIR), '', $path) . '/preview.png';
             $sliders[$handle]['preview'] = str_replace('\\', '/', $url);
         }
     }
     self::$sliders = array_merge(self::$sliders, $sliders);
     ksort(self::$sliders);
 }