-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9040319
commit 63489cb
Showing
16 changed files
with
1,211 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
/** | ||
* Stripe_Checkout_Block | ||
* | ||
* @package ThemeIsle\GutenbergBlocks\Render | ||
*/ | ||
|
||
namespace ThemeIsle\OtterPro\Render; | ||
|
||
use ThemeIsle\OtterPro\Plugins\License; | ||
/** | ||
* Class Modal_Block | ||
*/ | ||
class Modal_Block { | ||
|
||
/** | ||
* Block render function for server-side. | ||
* | ||
* This method will pe passed to the render_callback parameter and it will output | ||
* the server side output of the block. | ||
* | ||
* @param array $attributes The block attributes. | ||
* @param array $content The saved content. | ||
* @param \WP_Block $block The parsed block. | ||
* | ||
* @return mixed|string | ||
*/ | ||
public function render( $attributes, $content, $block ) { | ||
|
||
if ( ! License::has_active_license() ) { | ||
return ''; | ||
} | ||
|
||
if ( empty( $attributes['trigger'] ) ) { | ||
$attributes['trigger'] = 'onClick'; | ||
} | ||
|
||
$container_tag = '<div '; | ||
if ( ! empty( $attributes['id'] ) ) { | ||
$container_tag .= 'id="' . esc_attr( $attributes['id'] ) . '" '; | ||
} | ||
|
||
$classes = 'wp-block-themeisle-blocks-modal is-front '; | ||
if ( ! empty( $attributes['className'] ) ) { | ||
$classes .= esc_attr( $attributes['className'] ); | ||
} | ||
|
||
if ( ! empty( $attributes['closeButtonType'] ) && 'outside' === $attributes['closeButtonType'] ) { | ||
$classes .= 'with-outside-button'; | ||
} | ||
$container_tag .= 'class="' . $classes . '" '; | ||
|
||
if ( ! empty( $attributes['trigger'] ) ) { | ||
$container_tag .= 'data-open="' . esc_attr( $attributes['trigger'] ) . '" '; | ||
|
||
if ( 'onLoad' === $attributes['trigger'] ) { | ||
$container_tag .= 'data-time="' . ( ! empty( $attributes['wait'] ) ? esc_attr( $attributes['wait'] ) : 0 ) . '" '; | ||
} | ||
|
||
if ( 'onClick' === $attributes['trigger'] ) { | ||
$container_tag .= 'data-anchor="' . ( ! empty( $attributes['anchor'] ) ? esc_attr( $attributes['anchor'] ) : '' ) . '" '; | ||
} | ||
|
||
if ( 'onScroll' === $attributes['trigger'] ) { | ||
$container_tag .= 'data-offset="' . ( ! empty( $attributes['scroll'] ) ? esc_attr( $attributes['scroll'] ) : '' ) . '" '; | ||
} | ||
} | ||
|
||
if ( ! empty( $attributes['recurringClose'] ) ) { | ||
$container_tag .= 'data-dismiss="' . ( ! empty( $attributes['recurringTime'] ) ? esc_attr( $attributes['recurringTime'] ) : '' ) . '" '; | ||
} | ||
|
||
if ( ! empty( $attributes['outsideClose'] ) ) { | ||
$container_tag .= 'data-outside="' . esc_attr( $attributes['outsideClose'] ) . '" '; | ||
} | ||
|
||
if ( ! empty( $attributes['anchorClose'] ) ) { | ||
$container_tag .= 'data-anchorclose="' . esc_attr( $attributes['closeAnchor'] ) . '" '; | ||
} | ||
|
||
if ( ! empty( $attributes['lockScrolling'] ) ) { | ||
$container_tag .= 'data-lock-scrolling="1" '; | ||
} | ||
|
||
if ( ! empty( $attributes['disableOn'] ) ) { | ||
$container_tag .= 'data-disable-on="' . esc_attr( $attributes['disableOn'] ) . '" '; | ||
} | ||
|
||
$container_tag .= '>'; | ||
|
||
$modal_wrap = '<div class="otter-popup__modal_wrap">'; | ||
$modal_wrap .= '<div role="presentation" class="otter-popup__modal_wrap_overlay"></div>'; | ||
|
||
$modal_content = '<div class="otter-popup__modal_content">'; | ||
if ( ! empty( $attributes['showClose'] ) ) { | ||
$modal_content .= '<div class="otter-popup__modal_header">'; | ||
$modal_content .= '<button type="button" class="components-button has-icon">'; | ||
$modal_content .= '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true">'; | ||
$modal_content .= '<path d="M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"></path>'; | ||
$modal_content .= '</svg>'; | ||
$modal_content .= '</button>'; | ||
$modal_content .= '</div>'; | ||
} | ||
|
||
$modal_content .= '<div class="otter-popup__modal_body">'; | ||
foreach ( $block->inner_blocks as $inner_block ) { | ||
$modal_content .= $inner_block->render(); | ||
} | ||
$modal_content .= '</div>'; // Close otter-popup__modal_body. | ||
$modal_content .= '</div>'; // Close otter-popup__modal_content. | ||
|
||
$modal_wrap .= $modal_content; | ||
$modal_wrap .= '</div>'; // Close otter-popup__modal_wrap. | ||
|
||
$container_tag .= $modal_wrap; | ||
$container_tag .= '</div>'; // Close container tag. | ||
|
||
return $container_tag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "themeisle-blocks/modal", | ||
"title": "Modal", | ||
"category": "themeisle-blocks", | ||
"description": "Display your content in beautiful Modal with many customization options. Powered by Otter.", | ||
"keywords": [ "modal", "lightbox" ], | ||
"textdomain": "otter-blocks", | ||
"attributes": { | ||
"id": { | ||
"type": "string" | ||
}, | ||
"minWidth": { | ||
"type": ["number", "string"] | ||
}, | ||
"maxWidth": { | ||
"type": ["number", "string"] | ||
}, | ||
"trigger": { | ||
"type": "string" | ||
}, | ||
"wait": { | ||
"type": "number" | ||
}, | ||
"anchor": { | ||
"type": "string" | ||
}, | ||
"scroll": { | ||
"type": "number" | ||
}, | ||
"showClose": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"outsideClose": { | ||
"type": "boolean", | ||
"default": true | ||
}, | ||
"anchorClose": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"closeAnchor": { | ||
"type": "string" | ||
}, | ||
"recurringClose": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"recurringTime": { | ||
"type": "number" | ||
}, | ||
"backgroundColor": { | ||
"type": "string" | ||
}, | ||
"closeColor": { | ||
"type": "string" | ||
}, | ||
"overlayColor": { | ||
"type": "string" | ||
}, | ||
"overlayOpacity": { | ||
"type": "number" | ||
}, | ||
"lockScrolling": { | ||
"type": "boolean" | ||
}, | ||
"padding": { | ||
"type": "object" | ||
}, | ||
"paddingTablet": { | ||
"type": "object" | ||
}, | ||
"paddingMobile": { | ||
"type": "object" | ||
}, | ||
"borderWidth": { | ||
"type": "object" | ||
}, | ||
"borderRadius": { | ||
"type": "object" | ||
}, | ||
"borderColor": { | ||
"type": "string" | ||
}, | ||
"borderStyle": { | ||
"type": "string" | ||
}, | ||
"width": { | ||
"type": "string" | ||
}, | ||
"widthTablet": { | ||
"type": "string" | ||
}, | ||
"widthMobile": { | ||
"type": "string" | ||
}, | ||
"heightMode": { | ||
"type": "string" | ||
}, | ||
"height":{ | ||
"type": "string" | ||
}, | ||
"heightTablet":{ | ||
"type": "string" | ||
}, | ||
"heightMobile":{ | ||
"type": "string" | ||
}, | ||
"verticalPosition": { | ||
"type": "string" | ||
}, | ||
"horizontalPosition": { | ||
"type": "string" | ||
}, | ||
"verticalPositionTablet": { | ||
"type": "string" | ||
}, | ||
"horizontalPositionTablet": { | ||
"type": "string" | ||
}, | ||
"verticalPositionMobile": { | ||
"type": "string" | ||
}, | ||
"horizontalPositionMobile": { | ||
"type": "string" | ||
}, | ||
"closeButtonType": { | ||
"type": "string" | ||
}, | ||
"boxShadow": { | ||
"type": "object", | ||
"default": { | ||
"active": false, | ||
"colorOpacity": 50, | ||
"blur": 5, | ||
"spread": 1, | ||
"horizontal": 0, | ||
"vertical": 0 | ||
} | ||
}, | ||
"disableOn": { | ||
"type": "string" | ||
} | ||
}, | ||
"editorStyle": "otter-popup-editor", | ||
"style": "otter-popup-style", | ||
"script": "otter-popup" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor'; | ||
|
||
import { Placeholder } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
import { popupIcon as icon } from '../../helpers/icons'; | ||
|
||
const { name } = metadata; | ||
|
||
if ( ! Boolean( window.themeisleGutenberg.hasPro ) ) { | ||
registerBlockType( name, { | ||
...metadata, | ||
title: __( 'Modal (PRO)', 'otter-blocks' ), | ||
description: __( 'Display your content in beautiful Modal with many customization options. Powered by Otter.', 'otter-blocks' ), | ||
icon, | ||
keywords: [ | ||
'modal', | ||
'lightbox' | ||
], | ||
edit: () => { | ||
const instructions = sprintf( | ||
__( 'You need to activate your Otter Pro to use %1$s block.', 'otter-blocks' ), | ||
metadata.title | ||
); | ||
|
||
return ( | ||
<div { ...useBlockProps() }> | ||
<Placeholder | ||
icon={ icon } | ||
label={ metadata.title } | ||
instructions={ instructions } | ||
className="o-license-warning" | ||
/> | ||
</div> | ||
); | ||
}, | ||
save() { | ||
return ( | ||
<div className="otter-hide-content"> | ||
<InnerBlocks.Content /> | ||
</div> | ||
); | ||
}, | ||
example: { | ||
attributes: {} | ||
} | ||
}); | ||
} |
Oops, something went wrong.