--- a/image-viewer/build/admin/dashboard.asset.php
+++ b/image-viewer/build/admin/dashboard.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-i18n'), 'version' => '61c32651f09fdba18ce1');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-i18n'), 'version' => '57d48e8ca56333ba8ecd');
--- a/image-viewer/build/index.asset.php
+++ b/image-viewer/build/index.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-i18n'), 'version' => '4e69ccf3be9594fb5ae2');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-i18n'), 'version' => 'a13960b1237e48df4554');
--- a/image-viewer/build/render.php
+++ b/image-viewer/build/render.php
@@ -1,4 +1,7 @@
<?php
+ if (! defined('ABSPATH')) {
+ exit;
+ }
extract($attributes);
$id = wp_unique_id( 'bpivbImageViewer-' );
--- a/image-viewer/build/view.asset.php
+++ b/image-viewer/build/view.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-i18n'), 'version' => 'e969699ef63343b68e2d');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-i18n'), 'version' => '1da8164bc5736a7f000f');
--- a/image-viewer/image-viewer-block.php
+++ b/image-viewer/image-viewer-block.php
@@ -1,54 +1,124 @@
<?php
+if (! defined('ABSPATH')) {
+ exit;
+}
if (! class_exists('bpivbBlock')) {
- class bpivbBlock{
- public function __construct(){
- add_action('enqueue_block_assets', [$this, 'enqueueBlockAssets']);
- add_action('init', [$this, 'onInit']);
- add_action('enqueue_block_editor_assets', [$this, 'bpivbEnqueueBlockEditorAssets']);
- add_action('enqueue_block_assets', [$this, "bpivbFrontendScript"]);
- add_action('rest_api_init', function() {
- register_rest_route('bpivb/v1', '/image-proxy',
- [
- 'methods' => 'GET',
- 'callback' => function($data) {
- $url = $data->get_param('url');
-
- if (!$url) return new WP_Error('no_url', 'No URL provided', ['status' => 400]);
-
- $response = wp_remote_get($url);
- if (is_wp_error($response)) return new WP_Error('fetch_failed', 'Failed to fetch image', ['status' => 500]);
-
- $body = wp_remote_retrieve_body($response);
- $type = wp_remote_retrieve_header($response, 'content-type');
-
- header('Content-Type: ' . $type);
- echo $body;
- exit;
- }
- ]);
- });
-
- }
-
- public function enqueueBlockAssets(){
- wp_register_style('magnify', BPIVB_ASSETS_DIR . 'css/magnify.css', [], BPIVB_PLUGIN_VERSION);
- wp_register_script('panzoom', BPIVB_ASSETS_DIR . 'js/panzoom.min.js', ['jquery'], BPIVB_PLUGIN_VERSION);
- wp_register_script('magnify', BPIVB_ASSETS_DIR . 'js/magnify.js', ['jquery'], BPIVB_PLUGIN_VERSION);
- wp_register_script('three', BPIVB_ASSETS_DIR . 'js/three.min.js', [], BPIVB_PLUGIN_VERSION);
- wp_register_script('panoramajs', BPIVB_ASSETS_DIR . 'js/panorama.min.js', ["three","jquery"], BPIVB_PLUGIN_VERSION);
- }
-
- public function onInit(){
- register_block_type( __DIR__ . '/build' );
- }
-
- //edit.js aer moddhe bpivbIsPremium ta niye jasci / bpivb-image-viewer-directory ta block.json aer name ta akne Frontend Script a bcbIsPremium jabe
- public function bpivbEnqueueBlockEditorAssets(){
- wp_add_inline_script('bpivb-image-viewer-directory-editor-script', 'const bpivbPipecheck = ' . wp_json_encode(bpivbIsPremium()) . ';', 'before');
- }
- public function bpivbFrontendScript(){
- wp_add_inline_script('bpivb-image-viewer-directory-view-script', 'const bpivbPipecheck = ' . wp_json_encode(bpivbIsPremium()) . ';', 'before');
- }
+ class bpivbBlock
+ {
+ public function __construct()
+ {
+ add_action('enqueue_block_assets', [$this, 'enqueueBlockAssets']);
+ add_action('init', [$this, 'onInit']);
+ add_action('enqueue_block_editor_assets', [$this, 'bpivbEnqueueBlockEditorAssets']);
+ add_action('enqueue_block_assets', [$this, "bpivbFrontendScript"]);
+ add_action('rest_api_init', function () {
+ register_rest_route('bpivb/v1', '/image-proxy', [
+ 'methods' => 'GET',
+
+ //Permission check (prevents public abuse)
+ 'permission_callback' => function () {
+ return current_user_can('upload_files');
+ },
+
+ //Strict URL validation before callback runs
+ 'args' => [
+ 'url' => [
+ 'required' => true,
+ 'sanitize_callback' => 'esc_url_raw',
+ 'validate_callback' => function ($param) {
+
+ // Must be a valid URL
+ if (!wp_http_validate_url($param)) {
+ return false;
+ }
+
+ // Allow only http / https
+ $scheme = wp_parse_url($param, PHP_URL_SCHEME);
+ if (!in_array($scheme, ['http', 'https'], true)) {
+ return false;
+ }
+
+ return true;
+ },
+ ],
+ ],
+
+ 'callback' => function ($data) {
+ $url = $data->get_param('url');
+
+ if (!$url) {
+ return new WP_Error('no_url', 'No URL provided', ['status' => 400]);
+ }
+
+ $response = wp_remote_get($url);
+
+ if (is_wp_error($response)) {
+ return new WP_Error('fetch_failed', 'Failed to fetch image', ['status' => 500]);
+ }
+
+ $body = wp_remote_retrieve_body($response);
+ $type = wp_remote_retrieve_header($response, 'content-type');
+
+ header('Content-Type: ' . $type);
+ echo $body;
+ exit;
+ },
+ ]);
+ });
+
+ }
+
+ public function enqueueBlockAssets()
+ {
+ wp_register_style('magnify', BPIVB_ASSETS_DIR . 'css/magnify.css', [], BPIVB_PLUGIN_VERSION);
+ wp_register_script('panzoom', BPIVB_ASSETS_DIR . 'js/panzoom.min.js', ['jquery'], BPIVB_PLUGIN_VERSION);
+ wp_register_script('magnify', BPIVB_ASSETS_DIR . 'js/magnify.js', ['jquery'], BPIVB_PLUGIN_VERSION);
+ wp_register_script('three', BPIVB_ASSETS_DIR . 'js/three.min.js', [], BPIVB_PLUGIN_VERSION);
+ wp_register_script('panoramajs', BPIVB_ASSETS_DIR . 'js/panorama.min.js',
+ ["three", "jquery"], BPIVB_PLUGIN_VERSION);
+ }
+
+ public function onInit()
+ {
+ register_block_type(__DIR__ . '/build');
+ }
+
+ //edit.js aer moddhe bpivbIsPremium ta niye jasci
+ // / bpivb-image-viewer-directory ta block.json aer name ta akne Frontend Script a bcbIsPremium jabe
+
+ public function bpivbEnqueueBlockEditorAssets()
+ {
+ wp_add_inline_script('bpivb-image-viewer-directory-editor-script',
+ 'const bpivbPipecheck = ' . wp_json_encode(bpivbIsPremium()) . ';', 'before');
+
+ wp_localize_script(
+ 'bpivb-image-viewer-directory-editor-script',
+ 'BPIVB_REST',
+ [
+ 'root' => esc_url_raw(rest_url()),
+ 'nonce' => wp_create_nonce('wp_rest'),
+ ]
+ );
+
+ }
+
+ public function bpivbFrontendScript()
+ {
+ $data = [
+ 'isPremium' => function_exists('ctrbIsPremium') ? ctrbIsPremium() : false,
+ 'hasPro' => defined('CTRB_HAS_PRO') ? CTRB_HAS_PRO : false,
+ 'version' => defined('CTRB_VERSION') ? CTRB_VERSION : '',
+ ];
+ wp_add_inline_script('bpivb-image-viewer-directory-view-script',
+ 'const bpivbPipecheck = ' . wp_json_encode(bpivbIsPremium()) . ';', 'before');
+ wp_localize_script('bpivb-image-viewer-directory-view-script', 'BPIVB_REST',
+ [
+ 'root' => esc_url_raw(rest_url()),
+ 'nonce' => wp_create_nonce('wp_rest'),
+ ]
+ );
+ }
}
+
new bpivbBlock();
-}
No newline at end of file
+}
--- a/image-viewer/image-viewer.php
+++ b/image-viewer/image-viewer.php
@@ -3,7 +3,7 @@
/**
* Plugin Name: All In One Image Viewer
* Description: A powerful Gutenberg block plugin that lets you display images with advanced interactive features like zoom, magnify, map view, hotspots, and Comparison Slider.
- * Version: 1.0.2
+ * Version: 1.0.3
* Author: bPlugins
* Author URI: http://bplugins.com
* License: GPLv3
@@ -18,7 +18,7 @@
iv_fs()->set_basename( false, __FILE__ );
} else {
// Constant
- define( 'BPIVB_PLUGIN_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.0.2' ) );
+ define( 'BPIVB_PLUGIN_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.0.3' ) );
define( 'BPIVB_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'BPIVB_DIR', plugin_dir_url( __FILE__ ) );
define( 'BPIVB_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
--- a/image-viewer/includes/class-bpivbAdminMenu.php
+++ b/image-viewer/includes/class-bpivbAdminMenu.php
@@ -16,8 +16,8 @@
public function bpivb_AdminMenu_Create() {
add_submenu_page(
'edit.php?post_type=bpivb',
- __('Help - bPlugins', 'b-pricing-table'),
- __('Help And Demo', 'b-pricing-table'),
+ __('Help - bPlugins', 'image-viewer'),
+ __('Help And Demo', 'image-viewer'),
'manage_options',
'Image_viewer_block',
[$this, 'renderDashboardPage']
--- a/image-viewer/includes/class-bpivbPlugin.php
+++ b/image-viewer/includes/class-bpivbPlugin.php
@@ -1,4 +1,7 @@
<?php
+if (! defined('ABSPATH')) {
+ exit;
+}
if (! class_exists('bpivbPlugin')) {
class bpivbPlugin
--- a/image-viewer/includes/function.php
+++ b/image-viewer/includes/function.php
@@ -1,4 +1,7 @@
<?php
+if (! defined('ABSPATH')) {
+ exit;
+}
function bpivbIsPremium() {
return BPIVB_HAS_PRO ? iv_fs()->can_use_premium_code() : false;
}