Skip to content

Commit a9f5d72

Browse files
Merge pull request #72 from Codeinwp/development
Added Otter Option page Added update notice on Template Library Redesigned Google Map block Redesigned Post Grid block Removed Handsontable from Chart block
2 parents 3a6b2bc + 9da4801 commit a9f5d72

File tree

20 files changed

+1234
-12
lines changed

20 files changed

+1234
-12
lines changed

.distignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ artifact
1818
composer.json
1919
composer.lock
2020
package-lock.json
21-
themeisle-hash.json
21+
themeisle-hash.json
22+
vendor/codeinwp/gutenberg-blocks/src/**/*.js
23+
vendor/codeinwp/gutenberg-blocks/src/**/*.json
24+
vendor/codeinwp/gutenberg-blocks/src/**/*.scss
25+
!vendor/codeinwp/gutenberg-blocks/src/frontend/**/*.js
26+
vendor/codeinwp/gutenberg-css/src

.eslintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": "wordpress",
7+
"parserOptions": {
8+
"ecmaFeatures": {
9+
"jsx": true
10+
},
11+
"ecmaVersion": 2018,
12+
"sourceType": "module"
13+
},
14+
"plugins": [
15+
"react"
16+
],
17+
"rules": {
18+
"indent": [
19+
"error",
20+
"tab"
21+
],
22+
"linebreak-style": [
23+
"error",
24+
"unix"
25+
],
26+
"quotes": [
27+
"error",
28+
"single"
29+
],
30+
"semi": [
31+
"error",
32+
"always"
33+
]
34+
}
35+
}

assets/images/logo-alt.png

15 KB
Loading

assets/images/logo.png

20.3 KB
Loading

build/build.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/build.js

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

class-otter-blocks.php

Lines changed: 158 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class Otter_Blocks {
1010
/**
1111
* Otter_Blocks class instance.
1212
*
13+
* @since 1.0.0
14+
* @access public
1315
* @var Otter_Blocks
1416
*/
1517
public static $instance = null;
@@ -34,23 +36,175 @@ public function __construct() {
3436
public function init() {
3537
add_action( 'enqueue_block_assets', array( $this, 'enqueue_block_assets' ) );
3638
add_action( 'init', array( $this, 'load_gutenberg_blocks' ) );
39+
add_action( 'admin_menu', array( $this, 'register_menu_page' ) );
40+
add_action( 'init', array( $this, 'register_settings' ), 99 );
41+
add_action( 'admin_init', array( $this, 'maybe_redirect' ) );
3742
}
3843

3944
/**
4045
* Load assets for our blocks.
46+
*
47+
* @since 1.0.0
48+
* @access public
4149
*/
42-
function enqueue_block_assets() {
43-
wp_enqueue_style( 'font-awesome-5', plugins_url( 'assets/fontawesome/css/all.min.css', __FILE__ ) );
44-
wp_enqueue_style( 'font-awesome-4-shims', plugins_url( 'assets/fontawesome/css/v4-shims.min.css', __FILE__ ) );
50+
public function enqueue_block_assets() {
51+
if ( is_admin() || has_block( 'themeisle-blocks/button-group' ) || has_block( 'themeisle-blocks/font-awesome-icons' ) || has_block( 'themeisle-blocks/sharing-icons' ) || has_block( 'themeisle-blocks/plugin-cards' ) || has_block( 'block' ) ) {
52+
wp_enqueue_style( 'font-awesome-5', plugins_url( 'assets/fontawesome/css/all.min.css', __FILE__ ) );
53+
wp_enqueue_style( 'font-awesome-4-shims', plugins_url( 'assets/fontawesome/css/v4-shims.min.css', __FILE__ ) );
54+
}
4555
}
4656

4757
/**
4858
* Load Gutenberg Blocks
59+
*
60+
* @since 1.0.0
61+
* @access public
4962
*/
50-
function load_gutenberg_blocks() {
63+
public function load_gutenberg_blocks() {
64+
load_plugin_textdomain( 'otter-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' );
65+
5166
if ( class_exists( '\ThemeIsle\GutenbergBlocks' ) ) {
5267
\ThemeIsle\GutenbergBlocks::instance( $this->name );
5368
}
69+
70+
if ( class_exists( '\ThemeIsle\GutenbergCSS' ) && get_option( 'themeisle_blocks_settings_css_module', true ) ) {
71+
\ThemeIsle\GutenbergCSS::instance();
72+
}
73+
}
74+
75+
/**
76+
* Register Admin Page
77+
*
78+
* @since 1.2.0
79+
* @access public
80+
*/
81+
public function register_menu_page() {
82+
$page_hook_suffix = add_options_page(
83+
__( 'Otter', 'otter-blocks' ),
84+
__( 'Otter', 'otter-blocks' ),
85+
'manage_options',
86+
'otter',
87+
array( $this, 'menu_callback' )
88+
);
89+
90+
add_action( "admin_print_scripts-{$page_hook_suffix}", array( $this, 'enqueue_options_assets' ) );
91+
}
92+
93+
/**
94+
* Register Settings
95+
*
96+
* @since 1.2.0
97+
* @access public
98+
*/
99+
public function register_settings() {
100+
register_setting(
101+
'themeisle_blocks_settings',
102+
'themeisle_blocks_settings_redirect',
103+
array(
104+
'type' => 'boolean',
105+
'description' => __( 'Redirect on new install.', 'otter-blocks' ),
106+
'show_in_rest' => true,
107+
'default' => true,
108+
)
109+
);
110+
111+
register_setting(
112+
'themeisle_blocks_settings',
113+
'themeisle_blocks_settings_tour',
114+
array(
115+
'type' => 'boolean',
116+
'description' => __( 'Show tour for Otter.', 'otter-blocks' ),
117+
'show_in_rest' => true,
118+
'default' => true,
119+
)
120+
);
121+
122+
register_setting(
123+
'themeisle_blocks_settings',
124+
'themeisle_blocks_settings_css_module',
125+
array(
126+
'type' => 'boolean',
127+
'description' => __( 'Custom CSS module allows to add custom CSS to each block in Block Editor.', 'otter-blocks' ),
128+
'show_in_rest' => true,
129+
'default' => true,
130+
)
131+
);
132+
}
133+
134+
/**
135+
* Load assets for option page.
136+
*
137+
* @since 1.2.0
138+
* @access public
139+
*/
140+
public function enqueue_options_assets() {
141+
if ( OTTER_BLOCKS_DEV ) {
142+
$version = time();
143+
} else {
144+
$version = OTTER_BLOCKS_VERSION;
145+
}
146+
147+
$tour = get_option( 'themeisle_blocks_settings_tour' );
148+
149+
wp_enqueue_style(
150+
'otter-blocks-styles',
151+
plugins_url( 'build/build.css', __FILE__ ),
152+
array( 'wp-components' )
153+
);
154+
155+
wp_enqueue_script(
156+
'otter-blocks-scripts',
157+
plugins_url( 'build/build.js', __FILE__ ),
158+
array( 'react', 'react-dom', 'wp-i18n', 'wp-api', 'wp-components', 'wp-element' ),
159+
$version,
160+
true
161+
);
162+
163+
wp_localize_script(
164+
'otter-blocks-scripts', 'otterObj', array(
165+
'version' => OTTER_BLOCKS_VERSION,
166+
'assetsPath' => plugins_url( 'assets/', __FILE__ ),
167+
'showTour' => $tour,
168+
)
169+
);
170+
}
171+
172+
/**
173+
* Register Admin Page
174+
*
175+
* @since 1.2.0
176+
* @access public
177+
*/
178+
public function menu_callback() {
179+
echo '<div id="otter"></div>';
180+
}
181+
182+
/**
183+
* Maybe redirect to dashboard page.
184+
*
185+
* @since 1.2.0
186+
* @access public
187+
*/
188+
public function maybe_redirect() {
189+
if ( ! get_option( 'themeisle_blocks_settings_redirect' ) ) {
190+
return;
191+
}
192+
193+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
194+
return;
195+
}
196+
197+
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
198+
return;
199+
}
200+
201+
if ( ! get_option( 'themeisle_blocks_settings_tour' ) ) {
202+
return;
203+
}
204+
205+
update_option( 'themeisle_blocks_settings_redirect', false );
206+
wp_safe_redirect( admin_url( 'options-general.php?page=otter' ) );
207+
exit;
54208
}
55209

56210
/**

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"type": "wordpress-plugin",
55
"require": {
66
"codeinwp/gutenberg-blocks": "dev-master",
7+
"codeinwp/gutenberg-css": "dev-master",
78
"codeinwp/themeisle-sdk": "dev-master"
89
},
910
"license": "GPL-2.0+",

grunt/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
prefix: 'Version\\:\.*\\s'
1717
},
1818
src: [
19-
'otter-blocks.php',
19+
'otter.php',
2020
]
2121
}
2222
};

otter-blocks.php renamed to otter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Gutenberg Blocks and Template Library by Otter
44
* Plugin URI: https://themeisle.com/plugins/otter-blocks
55
* Description: Create beautiful and attracting posts, pages, and landing pages with Gutenberg Blocks and Template Library by Otter. Otter comes with dozens of Gutenberg blocks that are all you need to build beautiful pages.
6-
* Version: 1.1.5
6+
* Version: 1.2.0
77
* Author: ThemeIsle
88
* Author URI: https://themeisle.com
99
* License: GPL-2.0+
@@ -19,8 +19,11 @@
1919
die;
2020
}
2121

22+
define( 'OTTER_BLOCKS_BASEFILE', __FILE__ );
2223
define( 'OTTER_BLOCKS_URL', plugins_url( '/', __FILE__ ) );
2324
define( 'OTTER_BLOCKS_PATH', dirname( __FILE__ ) );
25+
define( 'OTTER_BLOCKS_VERSION', '1.2.0' );
26+
define( 'OTTER_BLOCKS_DEV', false );
2427

2528
$vendor_file = OTTER_BLOCKS_PATH . '/vendor/autoload.php';
2629
if ( is_readable( $vendor_file ) ) {

0 commit comments

Comments
 (0)