plugin_name = $plugin_name; $this->version = $version; } private function generateId() { $permitted_chars = implode('', range('a', 'z')); return 'jsv-' . '-' . substr(str_shuffle($permitted_chars), 0, 10); } public function add_360_icon($d, $e) { $bbCode = $this->getBBCode(); if (!empty($bbCode) and strlen($bbCode) > 10) { global $product; $attachment_ids = $product->get_gallery_image_ids(); if ($e == end($attachment_ids)) { $html = (new JSV_360_Parser($this->plugin_name, $this->version))->parse($bbCode); $htmlLarge = (new JSV_360_Parser($this->plugin_name, $this->version))->parse($bbCode); $randomId = $this->generateId(); $thumbImage = plugins_url('/img/icon.png', __FILE__); $text = sprintf( ' ', $thumbImage, $html, $randomId, $htmlLarge, $thumbImage, $randomId, $thumbImage ); return $d . $text; } } return $d; } private function getBBCode() { /** @var WC_Product $product */ global $product; return $product ? $product->get_meta(JSV_360_WOO_METABOX::FIELD_BBCODE) ?: null : null; } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.5.0 */ public function enqueue_scripts() { wp_enqueue_script( $this->plugin_name . '_woo_js', plugin_dir_url(__FILE__) . 'js/woo.js', array('javascriptviewer'), $this->version ); } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.5.0 */ public function enqueue_styles() { wp_enqueue_style( $this->plugin_name . '_woo_css', plugin_dir_url(__FILE__) . 'css/woo.css', array(), $this->version, 'all' ); } }