Skip to content

Commit de2f303

Browse files
committed
Prepare Gridable 1.2.10 for WordPress 7.0
1 parent cc17675 commit de2f303

12 files changed

Lines changed: 172 additions & 94 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ wp-content/plugins/hello.php
1818

1919
.sass-cache
2020
node_modules
21+
.claude
2122

2223
admin/css/*.map
2324
public/css/*.map
2425

25-
*.map
26+
*.map

admin/addons/attributes.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
2-
// print option html
2+
if ( ! defined( 'ABSPATH' ) ) {
3+
exit;
4+
}
5+
6+
// Print option HTML templates used by the Classic Editor media modal.
37
function gridable_default_attributes_modal_options_templates() { ?>
48
<script type="text/html" id="tmpl-gridable-row-option-color">
59
<fieldset class="colorpicker">
@@ -49,4 +53,4 @@ function gridable_default_attributes_modal_options_templates() { ?>
4953
</script>
5054

5155
<?php }
52-
add_action( 'gridable_print_row_options_templates', 'gridable_default_attributes_modal_options_templates' );
56+
add_action( 'gridable_print_row_options_templates', 'gridable_default_attributes_modal_options_templates' );

admin/class-gridable-admin.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
37
/**
48
* The admin-specific functionality of the plugin.
59
*
@@ -58,22 +62,33 @@ public function add_media_button( $editor_id ) {
5862
$icon = '<span class="wp-media-buttons-icon dashicons dashicons-layout" style="font-size:16px;margin-top:-2px;"></span>';
5963

6064
printf( '<a href="#" class="button gridable-insert-row-button" id="%s" data-editor="%s" title="%s">%s %s</a>',
61-
'gridable-add-row-button-' . $editor_id,
65+
esc_attr( 'gridable-add-row-button-' . $editor_id ),
6266
esc_attr( $editor_id ),
6367
esc_attr__( 'Add Row', 'gridable' ),
64-
$icon,
68+
wp_kses( $icon, array(
69+
'span' => array(
70+
'class' => true,
71+
'style' => true,
72+
),
73+
) ),
6574
esc_html__( 'Add Row', 'gridable' )
6675
);
6776

6877
/**
6978
* Enqueue the editor script only when there is an editor on page.
7079
* We ditch `admin_enqueue_scripts` intentionally since the editor can appear on non-edit pages like theme options
7180
*/
72-
wp_register_script( 'select2', plugin_dir_url( __FILE__ ) . 'js/select2.min.js', array( 'jquery' ), $this->version );
81+
wp_register_script( 'select2', plugin_dir_url( __FILE__ ) . 'js/select2.min.js', array( 'jquery' ), $this->version, true );
7382

7483
wp_enqueue_script( 'gridable-add-row-button', plugin_dir_url( __FILE__ ) . 'js/add-row-button.js', array(
84+
'backbone',
7585
'jquery',
86+
'media-editor',
87+
'media-views',
88+
'quicktags',
89+
'shortcode',
7690
'wp-color-picker',
91+
'wp-util',
7792
'select2',
7893
), $this->version, true );
7994

@@ -116,13 +131,13 @@ public function print_tinymce_templates() {
116131
$row_classes = array(
117132
'gridable',
118133
'gridable--grid',
119-
'grid'
134+
'grid',
120135
);
121136
$col_classes = array(
122-
'grid__item'
137+
'grid__item',
123138
); ?>
124-
<script type="text/html" id="tmpl-gridable-grider-row"><section contenteditable="false" class="{{data.classes}} <?php echo join( ' ', apply_filters( 'gridable_mce_sh_row_classes', $row_classes ) ); ?>" {{{data.atts}}} data-gridable-row="1" data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
125-
<script type="text/html" id="tmpl-gridable-grider-col"><section unselectable="true" contenteditable="true" class="{{data.classes}} <?php echo join( ' ', apply_filters( 'gridable_mce_sh_col_classes', $col_classes ) ); ?>" {{{data.atts}}} data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
139+
<script type="text/html" id="tmpl-gridable-grider-row"><section contenteditable="false" class="{{data.classes}} <?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', apply_filters( 'gridable_mce_sh_row_classes', $row_classes ) ) ) ); ?>" {{{data.atts}}} data-gridable-row="1" data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
140+
<script type="text/html" id="tmpl-gridable-grider-col"><section unselectable="true" contenteditable="true" class="{{data.classes}} <?php echo esc_attr( implode( ' ', array_map( 'sanitize_html_class', apply_filters( 'gridable_mce_sh_col_classes', $col_classes ) ) ) ); ?>" {{{data.atts}}} data-mce-resize="false" data-mce-placeholder="1">{{{data.content}}}</section></script>
126141
<?php
127142
do_action( 'gridable_print_row_options_templates' );
128143
do_action( 'gridable_print_column_options_templates' );
@@ -150,8 +165,8 @@ public function change_tinymce_settings( $settings ) {
150165

151166
public function styles_scripts() { ?>
152167
<script type="text/javascript">
153-
var gridable_params = {
154-
l10n: JSON.parse('<?php echo json_encode( apply_filters( 'gridable_editor_l10n_labels', array(
168+
window.gridable_params = window.gridable_params || {};
169+
window.gridable_params.l10n = <?php echo wp_json_encode( apply_filters( 'gridable_editor_l10n_labels', array(
155170
'remove_row' => esc_html__( 'Remove Row', 'gridable' ),
156171
'remove_column' => esc_html__( 'Remove Column', 'gridable' ),
157172
'edit_row' => esc_html__( 'Edit Row Options', 'gridable' ),
@@ -160,8 +175,7 @@ public function styles_scripts() { ?>
160175
'new_column_content' => esc_html__( 'Content', 'gridable' ),
161176
'column' => esc_html__( 'Column', 'gridable' ),
162177
'row' => esc_html__( 'Row', 'gridable' ),
163-
) ) ) ?>')
164-
};
178+
) ) ); ?>;
165179
</script>
166180
<?php
167181
}

gridable.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
* Plugin Name: Gridable
44
* Plugin URI: https://pixelgrade.com/
55
* Description: A simple and intuitive tool for organizing your content into columns and rows.
6-
* Version: 1.2.9
6+
* Version: 1.2.10
77
* Author: Pixelgrade
88
* Author URI: https://pixelgrade.com/
9-
* License: GPL-2.0+
9+
* License: GPL-2.0-or-later
1010
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
1111
* Text Domain: gridable
1212
* Domain Path: /languages
13-
* Requires at least: 4.9.9
14-
* Tested up to: 5.5.1
15-
* Requires PHP: 5.4.0
13+
* Requires at least: 5.9.0
14+
* Tested up to: 7.0
15+
* Requires PHP: 7.4
1616
*/
1717

1818
// If this file is called directly, abort.
@@ -24,7 +24,7 @@
2424
* The code that runs during plugin activation.
2525
* This action is documented in includes/class-gridable-activator.php
2626
*/
27-
function activate_gridable() {
27+
function gridable_activate() {
2828
require_once plugin_dir_path( __FILE__ ) . 'includes/class-gridable-activator.php';
2929
Gridable_Activator::activate();
3030
}
@@ -33,13 +33,13 @@ function activate_gridable() {
3333
* The code that runs during plugin deactivation.
3434
* This action is documented in includes/class-gridable-deactivator.php
3535
*/
36-
function deactivate_gridable() {
36+
function gridable_deactivate() {
3737
require_once plugin_dir_path( __FILE__ ) . 'includes/class-gridable-deactivator.php';
3838
Gridable_Deactivator::deactivate();
3939
}
4040

41-
register_activation_hook( __FILE__, 'activate_gridable' );
42-
register_deactivation_hook( __FILE__, 'deactivate_gridable' );
41+
register_activation_hook( __FILE__, 'gridable_activate' );
42+
register_deactivation_hook( __FILE__, 'gridable_deactivate' );
4343

4444
/**
4545
* The core plugin class that is used to define internationalization,
@@ -56,10 +56,10 @@ function deactivate_gridable() {
5656
*
5757
* @since 1.0.0
5858
*/
59-
function run_gridable() {
59+
function gridable_run() {
6060
global $gridable_plugin;
61-
$gridable_plugin = new Gridable( '1.2.9');
61+
$gridable_plugin = new Gridable( '1.2.10' );
6262
$gridable_plugin->run();
6363

6464
}
65-
run_gridable();
65+
gridable_run();

includes/class-gridable-i18n.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
37
/**
48
* Define the internationalization functionality
59
*
@@ -33,13 +37,7 @@ class Gridable_i18n {
3337
* @since 1.0.0
3438
*/
3539
public function load_plugin_textdomain() {
36-
37-
load_plugin_textdomain(
38-
'gridable',
39-
false,
40-
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
41-
);
42-
40+
// WordPress.org loads plugin language packs for this slug automatically.
4341
}
4442

4543

includes/class-gridable-loader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
37
/**
48
* Register all actions and filters for the plugin
59
*
@@ -102,7 +106,7 @@ private function add( $hooks, $hook, $component, $callback, $priority, $accepted
102106
'component' => $component,
103107
'callback' => $callback,
104108
'priority' => $priority,
105-
'accepted_args' => $accepted_args
109+
'accepted_args' => $accepted_args,
106110
);
107111

108112
return $hooks;

includes/class-gridable.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
if ( ! defined( 'ABSPATH' ) ) {
4+
exit;
5+
}
6+
37
/**
48
* The file that defines the core plugin class
59
*
@@ -162,7 +166,7 @@ protected function is_gutenberg_active() {
162166
* @return bool
163167
*/
164168
protected function is_classic_editor_plugin_active() {
165-
if ( class_exists( 'Classic_Editor') && method_exists('Classic_Editor', 'init_actions' ) ) {
169+
if ( class_exists( 'Classic_Editor' ) && method_exists( 'Classic_Editor', 'init_actions' ) ) {
166170
return true;
167171
}
168172

@@ -207,8 +211,10 @@ public function define_admin_hooks() {
207211

208212
add_action( 'media_buttons', array( $plugin_admin, 'add_media_button' ), 15 );
209213

210-
// Check if Gutenberg is active and if we are in the Editor screen
211-
if ( ! $this->is_gutenberg_active() && is_admin() ) {
214+
// Gridable's editing UI is intentionally limited to Classic Editor/TinyMCE.
215+
// Register the TinyMCE plugin whenever admin TinyMCE initializes so Classic Editor
216+
// per-post switching works even when the global default editor is the block editor.
217+
if ( is_admin() ) {
212218
add_filter( 'mce_external_plugins', array( $plugin_admin, 'add_tinymce_plugin' ) );
213219
}
214220

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gridable",
33
"repository": "git+https://github.com/pixelgrade/gridable.git",
44
"author": "Pixelgrade",
5-
"license": "GPL-2.0+",
5+
"license": "GPL-2.0-or-later",
66
"keywords": [
77
"Pixelgrade",
88
"Grid"
@@ -14,7 +14,7 @@
1414
"gulp-autoprefixer": "^6.0.0",
1515
"gulp-concat": "^2.6.1",
1616
"gulp-exec": "^3.0.2",
17-
"gulp-help": "github:chmontgomery/gulp-help#gulp4",
17+
"gulp-help": "git+https://github.com/chmontgomery/gulp-help.git#gulp4",
1818
"gulp-load-plugins": "*",
1919
"gulp-rsync": "*",
2020
"gulp-rtlcss": "^1.2.0",

0 commit comments

Comments
 (0)