Skip to content

Commit

Permalink
Merge pull request #1109 from publishpress/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
htmgarcia authored Nov 16, 2022
2 parents 55251d0 + b4bf58c commit 2feb0cf
Show file tree
Hide file tree
Showing 23 changed files with 2,710 additions and 2,348 deletions.
18 changes: 13 additions & 5 deletions src/advanced-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Plugin Name: PublishPress Blocks
* Plugin URI: https://publishpress.com/blocks/
* Description: PublishPress Blocks has everything you need to build professional websites with the Gutenberg editor.
* Version: 3.1.0
* Tested up to: 6.0.3
* Version: 3.1.1
* Tested up to: 6.1.1
* Author: PublishPress
* Author URI: https://publishpress.com/
* License: GPL2
Expand Down Expand Up @@ -41,8 +41,8 @@
$includeFilebRelativePath = '/publishpress/publishpress-instance-protection/include.php';
if (file_exists(__DIR__ . '/vendor' . $includeFilebRelativePath)) {
require_once __DIR__ . '/vendor' . $includeFilebRelativePath;
} else if (defined('PP_AUTHORS_VENDOR_PATH') && file_exists(PP_AUTHORS_VENDOR_PATH . $includeFilebRelativePath)) {
require_once PP_AUTHORS_VENDOR_PATH . $includeFilebRelativePath;
} else if (defined('ADVANCED_GUTENBERG_VENDOR_PATH') && file_exists(ADVANCED_GUTENBERG_VENDOR_PATH . $includeFilebRelativePath)) {
require_once ADVANCED_GUTENBERG_VENDOR_PATH . $includeFilebRelativePath;
}

if (class_exists('PublishPressInstanceProtection\\Config')) {
Expand All @@ -56,13 +56,21 @@
if (! defined('ADVANCED_GUTENBERG_LOADED')) {

if (! defined('ADVANCED_GUTENBERG_VERSION')) {
define('ADVANCED_GUTENBERG_VERSION', '3.1.0');
define('ADVANCED_GUTENBERG_VERSION', '3.1.1');
}

if (! defined('ADVANCED_GUTENBERG_PLUGIN')) {
define('ADVANCED_GUTENBERG_PLUGIN', __FILE__);
}

if ( ! defined( 'ADVANCED_GUTENBERG_BASE_PATH' ) ) {
define( 'ADVANCED_GUTENBERG_BASE_PATH', __DIR__ );
}

if ( ! defined( 'ADVANCED_GUTENBERG_VENDOR_PATH' ) ) {
define( 'ADVANCED_GUTENBERG_VENDOR_PATH', ADVANCED_GUTENBERG_BASE_PATH . '/vendor/' );
}

// Vendor and Ask-for-Review
if(
file_exists(__DIR__ . '/vendor/autoload.php')
Expand Down
65 changes: 65 additions & 0 deletions src/assets/blocks/0-adv-components/utils.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Generate option title suggestions
*
* @since 3.1.1
* @param options Available options as objects with slug and title. e.g. [{slug: 'subscriber', title: 'Subscriber'}, {slug: 'new_customer', title: 'New Customer'}]
*
* @return {array} Option slugs. e.g. ['subscriber','new_customer']
*/
export const getOptionSuggestions = function( options ) {
return options.map( ( item ) => item.title );
}

/**
* Match option slugs with its option titles
* to display as field value (but NOT saved!).
*
* @since 3.1.1
* @param slugs Option slugs. e.g. ['subscriber','new_customer']
* @param options Available options as objects with slug and title. e.g. [{slug: 'subscriber', title: 'Subscriber'}, {slug: 'new_customer', title: 'New Customer'}]
*
* @return {array} Option titles. e.g. ['Subscriber','New Customer']
*/
export const getOptionTitles = function( slugs, options ) {
let field_value = [];

if ( options !== null ) {
field_value = slugs.map( ( option_slug ) => {
let find_option = options.find( ( item ) => {
return item.slug === option_slug;
} );
if ( find_option === undefined || ! find_option ) {
return option_slug; // It should return false but creates empty selections
}
return find_option.title;
} );
}

return field_value;
}

/**
* Match option titles with its slugs, and save slugs
*
* @since 3.1.1
* @param slugs Option slugs. e.g. ['subscriber','new_customer']
* @param options Available options as objects with slug and title. e.g. [{slug: 'subscriber', title: 'Subscriber'}, {slug: 'new_customer', title: 'New Customer'}]
*
* @return {array} Option slugs. e.g. ['subscriber','new_customer']
*/
export const getOptionSlugs = function( slugs, options ) {
let slugs_array = [];

slugs.map(
( option_title ) => {
const matching_slug = options.find( ( item ) => {
return item.title === option_title;
} );
if ( matching_slug !== undefined ) {
slugs_array.push( matching_slug.slug );
}
}
)

return slugs_array;
}
14 changes: 14 additions & 0 deletions src/assets/blocks/advimage/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
jQuery(document).ready(function ( $ ) {
$('.advgb-image-block:not(.advgb-lightbox)').find('.advgb-image-overlay').each( function() {
if( $(this).attr('href') === undefined ) {
return;
}
var url = $(this).attr('href');
var target = $(this).attr('target');
if( url.length && target.length ) {
$(this).siblings().addClass('advgb-image-text--linkable').on( 'click', function() {
window.open(url, target);
});
}
});
});
Loading

0 comments on commit 2feb0cf

Please sign in to comment.