plugin_url = plugins_url('360-product-rotation/', YOFLA_360_PLUGIN_PATH); //set path to yofla360 folder within uploads $wp_uploads = wp_upload_dir(); $this->products_path = $wp_uploads['basedir'] . '/' . YOFLA_360_PRODUCTS_FOLDER . '/'; } /** * Add sytles and scripts for plugin media page */ function load_custom_wp_admin_style($hook) { if ($hook == 'media_page_yofla-360-media') { wp_register_style('yofla_360_add_media_css', $this->plugin_url . 'styles/add-media.css', false, '1.0.0'); wp_enqueue_style('yofla_360_add_media_css'); wp_register_script('yofla_360_add_media_js_add', $this->plugin_url . '/js/add-media.js', false, '1.0.0'); wp_enqueue_script('yofla_360_add_media_js_add'); } } /** * Add options page */ public function add_plugin_media_page() { // This page will be under "Settings" add_media_page( '360° Views', '360° Views', 'edit_posts', 'yofla-360-media', //menu slug array($this, 'create_plugin_media_page') ); } /** * Options page callback */ public function create_plugin_media_page() { $y360_options = get_option('yofla_360_options'); //read options stored in WP options database $is_using_license_id = !empty($y360_options['license_id']) && trim($y360_options['license_id']) !== ""; $is_using_license_key = !empty($y360_options['license_key']) && trim($y360_options['license_key']) !== ""; $is_using_license = $is_using_license_id || $is_using_license_key; $is_using_rotatetooljs_url = !empty($y360_options['rotatetooljs_url']) && filter_var($y360_options['rotatetooljs_url'], FILTER_VALIDATE_URL); $is_using_localengine = !empty($y360_options['local_engine']); $link_plugin_settings = 'Plugin Settings'; $link_creator = ' | Create new 360° view'; if ($is_using_license) { $license_info = ''; } else { /* $license_info = '

License info

'; $license_info .= '

You are using the free version of the player. You need set up your license'; $license_info .= ' in the plugin settings first.

'; */ $license_info = ''; } $lk = $y360_options['license_key']; $firstTwoChars = substr(strtolower($lk), 0, 2); $isCloudLicense = $firstTwoChars == 'yc'; $selfHostedViewsList = YoFLA360()->Utils()->get_yofla360_directories_list(); if ($lk) { if ($isCloudLicense) { // cloud license $selfHostedStyles = 'display: block;'; $cloudViesList = YoFLA360()->Utils()->get_cloud_projects_by_lk($lk); $cloudHostedText = $this->_formatProjectsList($cloudViesList); } else { // other license $cloudHostedText = 'Your license does not support cloud hosting of 360 views'; $selfHostedStyles = ''; } } if (!$is_using_license) { $selfHostedStyles = 'display: block;'; $cloudHostedText = 'No cloud-hosted files found...'; $cloudHostedText .= ' Please enter your license key in the Plugin settings first.'; } $selfHostedViewsScriptContent = $this->_formatSelfHostedProjectsList($selfHostedViewsList); ?>

360° Views :: Manage & Embed

Cloud-Hosted 360° Views

Self-Hosted 360° Views

_parse_size(ini_get('post_max_size')); // If upload_max_size is less, then reduce. Except if upload_max_size is // zero, which indicates no limit. $upload_max = $this->_parse_size(ini_get('upload_max_filesize')); if ($upload_max > 0 && $upload_max < $max_size) { $max_size = $upload_max; } } return $max_size; } private function _parse_size($size) { $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size. $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size. if ($unit) { // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by. return round($size * pow(1024, stripos('bkmgtpezy', $unit[0]))); } else { return round($size); } } private function _formatBytes($bytes, $precision = 2) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); // Uncomment one of the following alternatives $bytes /= pow(1024, $pow); // $bytes /= (1 << (10 * $pow)); return round($bytes, $precision) . ' ' . $units[$pow]; } private function _formatSelfHostedProjectsList($content) { if (!$content || sizeof($content) == 0) { return ''; } return "var selfHostedProjectsListData = " . json_encode($content) . ";"; } private function _formatProjectsList($items) { $out = ''; $link_plugin_settings = 'Plugin Settings'; if (!is_array($items)) { $out = 'No valid 360 views found for your license key. Please check your license key in ' . $link_plugin_settings; return $out; } foreach ($items as $item) { if(!isset($item['name'])) continue; $thumbnailUrl = $item['thumbnailUrl']; $name = $item['name']; $separator = ';'; $width = $item['playerWidth']; $height = $item['playerHeight']; $cid = $item['accountId'] . $separator . $item['projectId'] . $separator . $item['versionNumber']; $shortCode = "[360 src=\"$cid\" width=\"$width\" height=\"$height\" auto-height=\"true\"]"; $shortcodeInputId = "sc_" . $item['projectId']; $shortcodeNoteId = $shortcodeInputId . "_note"; $nameNew = "Test"; $thumbnailUrlNew = "https://www.yofla.com/3d-rotate/cdn/rotatetool/360-project-logo.png"; $out .= "
"; $out .= "
"; $out .= " "; $out .= "
"; $out .= "
"; $out .= "$name"; $out .= "
"; $out .= "
"; $out .= "

"; $out .= " "; $out .= " Updated: " . $item['updatedAt']; $out .= ", rev.#" . intVal($item['versionNumber']); $out .= " "; $out .= "

"; $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= "Copied!"; $out .= " "; $out .= "
"; $out .= "
"; } // link to crator to create new item at the end of the list $out .= "
"; $out .= "
"; $out .= " Create new "; $out .= "
"; $out .= " (opens in new window)"; $out .= "
"; $out .= "
"; $out .= "
"; return $out; } }