PluginProbe
WP Ultimate Post Grid / 3.4.0
WP Ultimate Post Grid v3.4.0
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / assets / js / shared / Button.js

Button.js in WP Ultimate Post Grid 3.4.0, at assets/js/shared/Button.js

48 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react';
2
3 import Tooltip from './Tooltip';
4
5 import '../../css/admin/shared/button.scss';
6
7 const Button = (props) => {
8 let buttonDisabled = false;
9 let tooltipContent = props.help ? props.help : false;
10 let className = 'button';
11
12 // Check if there are requirements.
13 if ( props.required ) {
14 if ( ! wpupg_admin.addons.hasOwnProperty( props.required ) || true !== wpupg_admin.addons[ props.required ] ) {
15 buttonDisabled = true;
16 const capitalized = props.required[0].toUpperCase() + props.required.substring(1);
17 tooltipContent = `WP Ultimate Post Grid ${capitalized} Bundle Only`;
18 }
19 }
20
21 // Extra class if primary button.
22 if ( props.isPrimary ) {
23 className += ' button-primary';
24 }
25
26 // Extra class if disabled. Don't actually use disabled or tooltip won't work.
27 if ( buttonDisabled ) {
28 className += ' wpupg-button-required';
29 }
30
31 return (
32 <Tooltip content={ tooltipContent }>
33 <button
34 className={ className }
35 tabIndex={ props.disableTab ? '-1' : null }
36 onClick={ buttonDisabled ? () => {
37 if ( confirm( 'Want to learn more about the version required for this feature?' ) ) {
38 window.open( 'https://bootstrapped.ventures/wp-ultimate-post-grid/get-the-plugin/', '_blank' );
39 }
40 } : props.onClick }
41 >
42 { props.children }
43 </button>
44 </Tooltip>
45 );
46 }
47
48 export default Button;