Ninja Tables – WP Data Table Plugin for WordPress - Version 1.4.0

Version Description

Download this release

Release Info

Developer techjewel
Plugin Icon 128x128 Ninja Tables – WP Data Table Plugin for WordPress
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.0 to 1.4.0

admin/NinjaTablesAdmin.php CHANGED
@@ -56,15 +56,15 @@ class NinjaTablesAdmin {
56
  */
57
  public function register_post_type() {
58
  register_post_type( $this->cpt_name, array(
59
- 'label' => __( 'Ninja Tables', 'ninja-tables' ),
60
- 'public' => false,
61
- 'show_ui' => true,
62
- 'show_in_menu' => false,
63
- 'capability_type' => 'post',
64
- 'hierarchical' => false,
65
- 'query_var' => false,
66
- 'supports' => array( 'title' ),
67
- 'labels' => array(
68
  'name' => __( 'Ninja Tables', 'ninja-tables' ),
69
  'singular_name' => __( 'Table', 'ninja-tables' ),
70
  'menu_name' => __( 'Ninja Tables', 'ninja-tables' ),
@@ -84,6 +84,7 @@ class NinjaTablesAdmin {
84
  ) );
85
  }
86
 
 
87
  /**
88
  * Adds a settings page link to a menu
89
  *
@@ -883,4 +884,85 @@ class NinjaTablesAdmin {
883
 
884
  die();
885
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
886
  }
56
  */
57
  public function register_post_type() {
58
  register_post_type( $this->cpt_name, array(
59
+ 'label' => __( 'Ninja Tables', 'ninja-tables' ),
60
+ 'public' => false,
61
+ 'show_ui' => true,
62
+ 'show_in_menu' => false,
63
+ 'capability_type' => 'post',
64
+ 'hierarchical' => false,
65
+ 'query_var' => false,
66
+ 'supports' => array( 'title' ),
67
+ 'labels' => array(
68
  'name' => __( 'Ninja Tables', 'ninja-tables' ),
69
  'singular_name' => __( 'Table', 'ninja-tables' ),
70
  'menu_name' => __( 'Ninja Tables', 'ninja-tables' ),
84
  ) );
85
  }
86
 
87
+
88
  /**
89
  * Adds a settings page link to a menu
90
  *
884
 
885
  die();
886
  }
887
+
888
+ public function add_tabales_to_editor() {
889
+ if ( user_can_richedit() ) {
890
+ $pages_with_editor_button = array( 'post.php', 'post-new.php' );
891
+ foreach ( $pages_with_editor_button as $editor_page ) {
892
+ add_action( "load-{$editor_page}", array( $this, 'init_ninja_mce_buttons' ) );
893
+ }
894
+ }
895
+ }
896
+
897
+ public function init_ninja_mce_buttons() {
898
+ add_filter( "mce_external_plugins", array($this, 'ninja_table_add_button') );
899
+ add_filter( 'mce_buttons', array($this, 'ninja_table_register_button') );
900
+ add_action('admin_footer', array($this, 'pushNinjaTablesToEditorFooter'));
901
+ }
902
+
903
+ public function pushNinjaTablesToEditorFooter() {
904
+ $tables = $this->getAllTablesForMce();
905
+ ?>
906
+ <script type="text/javascript">
907
+ window.ninja_tables_tiny_mce = {
908
+ label: '<?php _e('Select a Table to insert', 'ninja-tables') ?>',
909
+ title: '<?php _e('Insert Ninja Tables Shortcode', 'ninja-tables') ?>',
910
+ select_error: '<?php _e('Please select a table'); ?>',
911
+ insert_text: '<?php _e('Insert Shortcode', 'ninja-tables'); ?>',
912
+ tables: <?php echo json_encode($tables);?>
913
+ }
914
+ </script>
915
+ <?php
916
+ }
917
+
918
+ private function getAllTablesForMce() {
919
+ $args = array(
920
+ 'posts_per_page' => -1,
921
+ 'orderby' => 'date',
922
+ 'order' => 'DESC',
923
+ 'post_type' => $this->cpt_name,
924
+ 'post_status' => 'any'
925
+ );
926
+
927
+ $tables = get_posts( $args );
928
+ $formatted = array();
929
+ $formatted[] = array(
930
+ 'text' => __('Select a Table', 'ninja-tables'),
931
+ 'value' => ''
932
+ );
933
+
934
+ foreach ($tables as $table) {
935
+ $formatted[] = array(
936
+ 'text' => $table->post_title,
937
+ 'value' => $table->ID
938
+ );
939
+ }
940
+
941
+ return $formatted;
942
+ }
943
+
944
+
945
+ /**
946
+ * add a button to Tiny MCE editor
947
+ *
948
+ * @param $plugin_array
949
+ *
950
+ * @return mixed
951
+ */
952
+ public function ninja_table_add_button( $plugin_array ) {
953
+ $plugin_array['ninja_table'] = NINJA_TABLES_DIR_URL.'assets/js/ninja-table-tinymce-button.js';
954
+ return $plugin_array;
955
+ }
956
+
957
+ /**
958
+ * register a button to Tiny MCE editor
959
+ *
960
+ * @param $buttons
961
+ *
962
+ * @return mixed
963
+ */
964
+ public function ninja_table_register_button( $buttons ) {
965
+ array_push( $buttons, 'ninja_table' );
966
+ return $buttons;
967
+ }
968
  }
assets/img/ninja-table-editor-button-2x.png ADDED
Binary file
assets/js/ninja-table-tinymce-button.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.ninja_table', {
3
+ init : function(editor, url) {
4
+ editor.addButton('ninja_table', {
5
+ title : 'Add Ninja Tables Shortcode',
6
+ cmd : 'ninja_table_action',
7
+ image : url.slice( 0, url.length - 2 ) + 'img/ninja-table-editor-button-2x.png',
8
+ });
9
+ editor.addCommand('ninja_table_action', function() {
10
+ editor.windowManager.open({
11
+ title: window.ninja_tables_tiny_mce.title,
12
+ body: [
13
+ {
14
+ type : 'listbox',
15
+ name : 'ninja_table_shortcode',
16
+ label : window.ninja_tables_tiny_mce.label,
17
+ values : window.ninja_tables_tiny_mce.tables
18
+ }
19
+ ],
20
+ width: 768,
21
+ height: 100,
22
+ onsubmit: function( e ) {
23
+ if( e.data.ninja_table_shortcode ) {
24
+ editor.insertContent( '[ninja_tables id="' + e.data.ninja_table_shortcode + '"]');
25
+ } else {
26
+ alert(window.ninja_tables_tiny_mce.select_error);
27
+ return false;
28
+ }
29
+ },
30
+ buttons: [
31
+ {
32
+ text: window.ninja_tables_tiny_mce.insert_text,
33
+ subtype: 'primary',
34
+ onclick: 'submit'
35
+ }
36
+ ]
37
+ }, {
38
+ 'tinymce': tinymce
39
+ });
40
+ });
41
+ },
42
+ // ... Hidden code
43
+ });
44
+ // Register plugin
45
+ tinymce.PluginManager.add( 'ninja_table', tinymce.plugins.ninja_table );
46
+ })();
includes/NinjaTableClass.php CHANGED
@@ -161,15 +161,13 @@ class NinjaTableClass {
161
  private function define_admin_hooks() {
162
 
163
  $plugin_admin = new NinjaTablesAdmin( $this->get_plugin_name(), $this->get_version() );
164
-
165
  $this->loader->add_action( 'init', $plugin_admin, 'register_post_type' );
166
-
167
  $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' );
168
-
169
  $this->loader->add_action('wp_ajax_ninja_tables_ajax_actions',
170
  $plugin_admin,
171
  'ajax_routes'
172
  );
 
173
  }
174
 
175
  /**
161
  private function define_admin_hooks() {
162
 
163
  $plugin_admin = new NinjaTablesAdmin( $this->get_plugin_name(), $this->get_version() );
 
164
  $this->loader->add_action( 'init', $plugin_admin, 'register_post_type' );
 
165
  $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu' );
 
166
  $this->loader->add_action('wp_ajax_ninja_tables_ajax_actions',
167
  $plugin_admin,
168
  'ajax_routes'
169
  );
170
+ $this->loader->add_action('init', $plugin_admin, 'add_tabales_to_editor');
171
  }
172
 
173
  /**
includes/libs/TableDrivers/NinjaFooTable.php CHANGED
@@ -89,18 +89,13 @@ class NinjaFooTable
89
  'columns' => $formatted_columns,
90
  'settings' => $configSettings
91
  );
92
-
93
  self::addInlineVars( json_encode($table_vars, true) , $table_id);
94
  ?>
95
-
96
- <div id="footable_parent_<?php echo $table_id; ?>"
97
- class="footable_parent wp_table_data_press_parent <?php echo $settings['css_lib']; ?> <?php echo $tableHasColor; ?>">
98
-
99
  <?php if (isset($settings['show_title'])
100
  && $settings['show_title']
101
  ) : ?>
102
- <?php do_action('ninja_tables_before_table_title', $table); ?>
103
- <h3 class="table_title footable_title"><?php echo esc_attr($table->post_title); ?></h3>
104
  <?php do_action('ninja_tables_after_table_title', $table); ?>
105
  <?php endif; ?>
106
  <?php if (isset($settings['show_description'])
@@ -112,7 +107,6 @@ class NinjaFooTable
112
  <?php do_action('ninja_tables_after_table_description',
113
  $table); ?>
114
  <?php endif; ?>
115
-
116
  <?php do_action('ninja_tables_before_table_print', $table); ?>
117
  <table
118
  data-footable_id="<?php echo intval($table_id); ?>"
@@ -122,7 +116,6 @@ class NinjaFooTable
122
  </table>
123
  <?php do_action('ninja_tables_after_table_print', $table); ?>
124
  </div>
125
-
126
  <?php
127
  }
128
 
89
  'columns' => $formatted_columns,
90
  'settings' => $configSettings
91
  );
 
92
  self::addInlineVars( json_encode($table_vars, true) , $table_id);
93
  ?>
94
+ <div id="footable_parent_<?php echo $table_id; ?>" class="footable_parent wp_table_data_press_parent <?php echo $settings['css_lib']; ?> <?php echo $tableHasColor; ?>">
 
 
 
95
  <?php if (isset($settings['show_title'])
96
  && $settings['show_title']
97
  ) : ?>
98
+ <?php do_action('ninja_tables_before_table_title', $table); ?><h3 class="table_title footable_title"><?php echo esc_attr($table->post_title); ?></h3>
 
99
  <?php do_action('ninja_tables_after_table_title', $table); ?>
100
  <?php endif; ?>
101
  <?php if (isset($settings['show_description'])
107
  <?php do_action('ninja_tables_after_table_description',
108
  $table); ?>
109
  <?php endif; ?>
 
110
  <?php do_action('ninja_tables_before_table_print', $table); ?>
111
  <table
112
  data-footable_id="<?php echo intval($table_id); ?>"
116
  </table>
117
  <?php do_action('ninja_tables_after_table_print', $table); ?>
118
  </div>
 
119
  <?php
120
  }
121
 
ninja-tables.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Ninja Tables
17
  * Plugin URI: https://wpmanageninja.com/plugins/ninja-tables/
18
  * Description: The Easiest & Fastest Responsive Table Plugin on WordPress. Multiple templates, drag-&-drop live table builder, multiple color scheme, and styles.
19
- * Version: 1.3.0
20
  * Author: WPManageNinja
21
  * Author URI: https://wpmanageninja.com/
22
  * License: GPL-2.0+
16
  * Plugin Name: Ninja Tables
17
  * Plugin URI: https://wpmanageninja.com/plugins/ninja-tables/
18
  * Description: The Easiest & Fastest Responsive Table Plugin on WordPress. Multiple templates, drag-&-drop live table builder, multiple color scheme, and styles.
19
+ * Version: 1.4.0
20
  * Author: WPManageNinja
21
  * Author URI: https://wpmanageninja.com/
22
  * License: GPL-2.0+
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: WordPress tables Plugin, wp tables, data tables, datatables plugin, table
5
  Requires at least: 4.0
6
  Requires PHP: 5.3 or greater
7
  Tested up to: 4.9
8
- Stable tag: 1.3.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -101,7 +101,7 @@ Yes, You can use any shortcodes in table cells. This featured is available since
101
 
102
  == Screenshots ==
103
 
104
- 1. Frontend Preview
105
  2. Backend - Table Data Update
106
  3. Backend - Table Configuration
107
  4. Backend - Add Table Column
5
  Requires at least: 4.0
6
  Requires PHP: 5.3 or greater
7
  Tested up to: 4.9
8
+ Stable tag: 1.4.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
101
 
102
  == Screenshots ==
103
 
104
+ 1. Backend - Table Data View
105
  2. Backend - Table Data Update
106
  3. Backend - Table Configuration
107
  4. Backend - Add Table Column