Skip to content

Commit

Permalink
Adding in the jsEditor params to allow embedding of images in the plu…
Browse files Browse the repository at this point in the history
…gin.
  • Loading branch information
krugazul committed Dec 5, 2024
1 parent f9e7883 commit 24d69ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
8 changes: 4 additions & 4 deletions assets/js/blocks/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ wp.domReady(() => {
},
[
['core/image', {
width: 20,
width: '20px',
sizeSlug: 'large',
url: 'http://localhost:8883/wp-content/themes/lsx-tour-operator/assets/images/Typetype-icon.png',
url: 'https://tour-operator.lsx.design/wp-content/uploads/2024/06/image-1.png',
alt: ''
}],
['core/paragraph', {
Expand Down Expand Up @@ -244,9 +244,9 @@ wp.domReady(() => {
},
[
['core/image', {
width: 20,
width: '20px',
sizeSlug: 'large',
url: 'http://localhost:8883/wp-content/themes/lsx-tour-operator/assets/images/best-months-to-travel-TO-icon-black-20px-1-1.png',
url: lsxToEditor.homeUrl + 'wp-content/uploads/2024/11/booking-validity-icon-black-52px-1.svg',
alt: ''
}],
['core/paragraph', {
Expand Down
41 changes: 24 additions & 17 deletions includes/classes/blocks/class-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ public function __construct() {
public function enqueue_block_variations_script() {

$scripts = [
'general' => '',
'tour' => '',
'accommodation' => '',
'destination' => '',
'query-loops' => '',
'general' => array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ),
'tour' => array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post', 'lsx-to-block-general-variations' ),
'accommodation' => array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post', 'lsx-to-block-general-variations' ),
'destination' => array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post', 'lsx-to-block-general-variations' ),
'query-loops' => array( 'wp-blocks', 'wp-dom-ready', 'wp-edit-post', 'lsx-to-block-general-variations' ),
];

$additional_scripts = [
'linked-cover' => array( 'wp-blocks', 'wp-element', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-data', 'wp-hooks' ),
'slider-query' => array( 'wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-compose' ),
'onsale-query' => array( 'wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-compose' ),
];

// Make sure the script is only enqueued in the block editor.
Expand All @@ -60,6 +59,14 @@ public function enqueue_block_variations_script() {
filemtime( LSX_TO_PATH . 'assets/js/blocks/' . $slug . '.js' ), // Versioning with file modification time.
true // Enqueue in the footer.
);
if ( 'general' === $slug ) {
$param_array = array(
'homeUrl' => trailingslashit( home_url() ),
'assetsUrl' => LSX_TO_URL . 'assets/img/'
);
$param_array = apply_filters( 'lsx_to_editor_params', $param_array );
wp_localize_script( 'lsx-to-block-' . $slug . '-variations', 'lsxToEditor', $param_array );
}
}

foreach ( $additional_scripts as $slug => $dependancies ) {
Expand Down Expand Up @@ -367,17 +374,17 @@ public function maybe_hide_varitaion( $block_content, $parsed_block, $block_obj
}

/**
* Determines if a post exists based on the ID.
*
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $title Post title.
* @param string $content Optional. Post content.
* @param string $date Optional. Post date.
* @param string $type Optional. Post type.
* @param string $status Optional. Post status.
* @return int Post ID if post exists, 0 otherwise.
* Determines if a post exists based on the ID.
*
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $title Post title.
* @param string $content Optional. Post content.
* @param string $date Optional. Post date.
* @param string $type Optional. Post type.
* @param string $status Optional. Post status.
* @return int Post ID if post exists, 0 otherwise.
*/
protected function post_ids_exist( $ids ) {
global $wpdb;
Expand Down

0 comments on commit 24d69ed

Please sign in to comment.