| @@ -32,14 +32,18 @@ | ||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function bBlocks_cursor_data_settings(){ |
| 35 | 35 | |
| 36 | - if (!wp_verify_nonce(sanitize_text_field(isset($_POST['nonce']) ? stripcslashes($_POST['nonce']) : null), 'wp_ajax')) { | |
| 37 | - wp_send_json_error('invalid request'); | |
| 36 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ?? '' ) ), 'wp_ajax' ) ) { | |
| 37 | + wp_send_json_error( 'invalid request' ); | |
| 38 | 38 | } |
| 39 | - | |
| 40 | - $data = json_decode(sanitize_text_field( stripcslashes($_POST['bBlocksCustomCursor'])), true); | |
| 41 | 39 | |
| 40 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 41 | + wp_send_json_error( 'Unauthorized' ); | |
| 42 | + } | |
| 43 | + | |
| 44 | + $data = json_decode( sanitize_text_field( wp_unslash( $_POST['bBlocksCustomCursor'] ?? '' ) ), true ); | |
| 45 | + | |
| 42 | 46 | if(!$data){ |
| 43 | 47 | $data = get_option('bBlocks_custom_cursor_settings', []); |
| 44 | 48 | wp_send_json_success($data); |
| 45 | 49 | } |
| @@ -50,9 +54,9 @@ | ||
| 50 | 54 | |
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | public function bBlocks_get_cursor_data_settings(){ |
| 54 | - if (!wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'wp_ajax')) { | |
| 58 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ?? '' ) ), 'wp_ajax' ) ) { | |
| 55 | 59 | wp_send_json_error('invalid request'); |
| 56 | 60 | } |
| 57 | 61 | |
| 58 | 62 | $data = get_option('bBlocks_custom_cursor_settings', []); |
| @@ -61,9 +65,9 @@ | ||
| 61 | 65 | |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | 68 | public function bBlocksEnqueueBlockAssets() { |
| 65 | - wp_enqueue_script( 'bBlocks-cursor', B_BLOCKS_DIR_URL . 'build/cursor/cursor.js', array('react', 'react-dom', 'wp-util'), B_BLOCKS_VERSION, true); | |
| 69 | + wp_enqueue_script( 'bBlocks-cursor', B_BLOCKS_DIR_URL . 'build/cursor/cursor.js', array('react', 'react-dom', 'react-jsx-runtime', 'wp-util'), B_BLOCKS_VERSION, true); | |
| 66 | 70 | wp_enqueue_style( 'bBlocks-cursor', B_BLOCKS_DIR_URL . 'build/cursor/cursor.css', array(), B_BLOCKS_VERSION); |
| 67 | 71 | |
| 68 | 72 | wp_localize_script( 'bBlocks-cursor', 'bBlocksCursorDataConfig', array( |
| 69 | 73 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| @@ -72,10 +76,10 @@ | ||
| 72 | 76 | )); |
| 73 | 77 | } |
| 74 | 78 | |
| 75 | 79 | function bBlocksEnqueueBlockEditorAssets(){ |
| 76 | - wp_enqueue_script('bBlocks-cursor-settings', B_BLOCKS_DIR_URL . 'build/cursor/settings.js', array('wp-compose','wp-data','wp-editor','wp-plugins','wp-components','wp-i18n','react','react-dom'), B_BLOCKS_VERSION, true); | |
| 80 | + wp_enqueue_script('bBlocks-cursor-settings', B_BLOCKS_DIR_URL . 'build/cursor/settings.js', array('wp-compose','wp-data','wp-editor','wp-plugins','wp-components','wp-i18n','react','react-dom','react-jsx-runtime'), B_BLOCKS_VERSION, true); | |
| 77 | 81 | wp_enqueue_style("bBlocks-cursor-settings", B_BLOCKS_DIR_URL . 'build/cursor/settings.css', array(), B_BLOCKS_VERSION); |
| 78 | 82 | } |
| 79 | 83 | } |
| 80 | 84 | new BBlocksCustomCursor(); |
| 81 | 85 | } |