Ultimate FAQ - Version 2.1.13

Version Description

(2022-05-17) = - Added previews for Gutenberg blocks (i.e. when, on the page edit screen, you add the block, it will show a preview).

Download this release

Release Info

Developer Rustaurius
Plugin Icon 128x128 Ultimate FAQ
Version 2.1.13
Comparing to
See all releases

Code changes from version 2.1.12 to 2.1.13

assets/css/ewd-ufaq-blocks.css CHANGED
@@ -7,3 +7,13 @@ BLOCKS
7
  font-size: 22px;
8
  font-weight: bold;
9
  }
 
 
 
 
 
 
 
 
 
 
7
  font-size: 22px;
8
  font-weight: bold;
9
  }
10
+
11
+ .wp-admin .ewd-ufaq-question-form form input,
12
+ .wp-admin .ewd-ufaq-question-form form textarea,
13
+ .wp-admin .ewd-ufaq-question-form form select {
14
+ pointer-events: none;
15
+ }
16
+
17
+ .wp-admin input[name="submit_question"] {
18
+ display: none;
19
+ }
assets/js/ewd-ufaq-blocks.js CHANGED
@@ -2,14 +2,19 @@ var el = wp.element.createElement,
2
  registerBlockType = wp.blocks.registerBlockType,
3
  ServerSideRender = wp.components.ServerSideRender,
4
  TextControl = wp.components.TextControl,
5
- InspectorControls = wp.editor.InspectorControls;
 
 
6
 
7
  registerBlockType( 'ultimate-faqs/ewd-ufaq-display-faq-block', {
8
- title: 'Display FAQs',
9
  icon: 'editor-help',
10
  category: 'ewd-ufaq-blocks',
11
  attributes: {
12
- post_count: { type: 'string' },
 
 
 
13
  include_category: { type: 'string' },
14
  exclude_category: { type: 'string' },
15
  },
@@ -19,23 +24,27 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-display-faq-block', {
19
  returnString.push(
20
  el( InspectorControls, {},
21
  el( TextControl, {
22
- label: 'Number of FAQs',
 
23
  value: props.attributes.post_count,
24
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
25
  } ),
26
  el( TextControl, {
27
- label: 'Include Category',
28
  value: props.attributes.include_category,
29
  onChange: ( value ) => { props.setAttributes( { include_category: value } ); },
30
  } ),
31
  el( TextControl, {
32
- label: 'Exclude Category',
33
  value: props.attributes.exclude_category,
34
  onChange: ( value ) => { props.setAttributes( { exclude_category: value } ); },
35
  } )
36
  ),
37
  );
38
- returnString.push( el( 'div', { class: 'ewd-ufaq-admin-block ewd-ufaq-admin-block-display-faqs' }, 'Display FAQs Block' ) );
 
 
 
39
  return returnString;
40
  },
41
 
@@ -45,7 +54,7 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-display-faq-block', {
45
  } );
46
 
47
  registerBlockType( 'ultimate-faqs/ewd-ufaq-search-block', {
48
- title: 'Search FAQs',
49
  icon: 'editor-help',
50
  category: 'ewd-ufaq-blocks',
51
  attributes: {
@@ -59,23 +68,26 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-search-block', {
59
  returnString.push(
60
  el( InspectorControls, {},
61
  el( TextControl, {
62
- label: 'Include Category',
63
  value: props.attributes.include_category,
64
  onChange: ( value ) => { props.setAttributes( { include_category: value } ); },
65
  } ),
66
  el( TextControl, {
67
- label: 'Exclude Category',
68
  value: props.attributes.exclude_category,
69
  onChange: ( value ) => { props.setAttributes( { exclude_category: value } ); },
70
  } ),
71
- el( TextControl, {
72
- label: 'Show all FAQs on Page Load? (Yes or No)',
73
  value: props.attributes.show_on_load,
 
74
  onChange: ( value ) => { props.setAttributes( { show_on_load: value } ); },
75
  } )
76
  ),
77
  );
78
- returnString.push( el( 'div', { class: 'ewd-ufaq-admin-block ewd-ufaq-admin-block-search-faqs' }, 'Search FAQs Block' ) );
 
 
79
  return returnString;
80
  },
81
 
@@ -85,7 +97,7 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-search-block', {
85
  } );
86
 
87
  registerBlockType( 'ultimate-faqs/ewd-ufaq-submit-faq-block', {
88
- title: 'Submit FAQ',
89
  icon: 'editor-help',
90
  category: 'ewd-ufaq-blocks',
91
  attributes: {
@@ -93,7 +105,9 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-submit-faq-block', {
93
 
94
  edit: function( props ) {
95
  var returnString = [];
96
- returnString.push( el( 'div', { class: 'ewd-ufaq-admin-block ewd-ufaq-admin-block-submit-faq' }, 'Submit Question Block' ) );
 
 
97
  return returnString;
98
  },
99
 
@@ -103,11 +117,14 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-submit-faq-block', {
103
  } );
104
 
105
  registerBlockType( 'ultimate-faqs/ewd-ufaq-recent-faqs-block', {
106
- title: 'Recent FAQs',
107
  icon: 'editor-help',
108
  category: 'ewd-ufaq-blocks',
109
  attributes: {
110
- post_count: { type: 'string' },
 
 
 
111
  },
112
 
113
  edit: function( props ) {
@@ -115,13 +132,17 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-recent-faqs-block', {
115
  returnString.push(
116
  el( InspectorControls, {},
117
  el( TextControl, {
118
- label: 'Number of FAQs',
 
119
  value: props.attributes.post_count,
120
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
121
  } )
122
  ),
123
  );
124
- returnString.push( el( 'div', { class: 'ewd-ufaq-admin-block ewd-ufaq-admin-block-recent-faqs' }, 'Recent FAQs Block' ) );
 
 
 
125
  return returnString;
126
  },
127
 
@@ -131,11 +152,14 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-recent-faqs-block', {
131
  } );
132
 
133
  registerBlockType( 'ultimate-faqs/ewd-ufaq-popular-faqs-block', {
134
- title: 'Popular FAQs',
135
  icon: 'editor-help',
136
  category: 'ewd-ufaq-blocks',
137
  attributes: {
138
- post_count: { type: 'string' },
 
 
 
139
  },
140
 
141
  edit: function( props ) {
@@ -143,13 +167,17 @@ registerBlockType( 'ultimate-faqs/ewd-ufaq-popular-faqs-block', {
143
  returnString.push(
144
  el( InspectorControls, {},
145
  el( TextControl, {
146
- label: 'Number of FAQs',
 
147
  value: props.attributes.post_count,
148
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
149
  } )
150
  ),
151
  );
152
- returnString.push( el( 'div', { class: 'ewd-ufaq-admin-block ewd-ufaq-admin-block-popular-faqs' }, 'Popular FAQs Block' ) );
 
 
 
153
  return returnString;
154
  },
155
 
2
  registerBlockType = wp.blocks.registerBlockType,
3
  ServerSideRender = wp.components.ServerSideRender,
4
  TextControl = wp.components.TextControl,
5
+ SelectControl = wp.components.SelectControl,
6
+ InspectorControls = wp.editor.InspectorControls,
7
+ Localize = wp.i18n.__;
8
 
9
  registerBlockType( 'ultimate-faqs/ewd-ufaq-display-faq-block', {
10
+ title: Localize( 'Display FAQs', 'ultimate-faqs' ),
11
  icon: 'editor-help',
12
  category: 'ewd-ufaq-blocks',
13
  attributes: {
14
+ post_count: {
15
+ type: 'string',
16
+ default: -1
17
+ },
18
  include_category: { type: 'string' },
19
  exclude_category: { type: 'string' },
20
  },
24
  returnString.push(
25
  el( InspectorControls, {},
26
  el( TextControl, {
27
+ type: 'number',
28
+ label: Localize( 'Number of FAQs', 'ultimate-faqs' ),
29
  value: props.attributes.post_count,
30
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
31
  } ),
32
  el( TextControl, {
33
+ label: Localize( 'Include Category', 'ultimate-faqs' ),
34
  value: props.attributes.include_category,
35
  onChange: ( value ) => { props.setAttributes( { include_category: value } ); },
36
  } ),
37
  el( TextControl, {
38
+ label: Localize( 'Exclude Category', 'ultimate-faqs' ),
39
  value: props.attributes.exclude_category,
40
  onChange: ( value ) => { props.setAttributes( { exclude_category: value } ); },
41
  } )
42
  ),
43
  );
44
+ returnString.push( el( ServerSideRender, {
45
+ block: 'ultimate-faqs/ewd-ufaq-display-faq-block',
46
+ attributes: props.attributes
47
+ } ) );
48
  return returnString;
49
  },
50
 
54
  } );
55
 
56
  registerBlockType( 'ultimate-faqs/ewd-ufaq-search-block', {
57
+ title: Localize( 'Search FAQs', 'ultimate-faqs' ),
58
  icon: 'editor-help',
59
  category: 'ewd-ufaq-blocks',
60
  attributes: {
68
  returnString.push(
69
  el( InspectorControls, {},
70
  el( TextControl, {
71
+ label: Localize( 'Include Category', 'ultimate-faqs' ),
72
  value: props.attributes.include_category,
73
  onChange: ( value ) => { props.setAttributes( { include_category: value } ); },
74
  } ),
75
  el( TextControl, {
76
+ label: Localize( 'Exclude Category', 'ultimate-faqs' ),
77
  value: props.attributes.exclude_category,
78
  onChange: ( value ) => { props.setAttributes( { exclude_category: value } ); },
79
  } ),
80
+ el( SelectControl, {
81
+ label: Localize( 'Show all FAQs on Page Load?', 'ultimate-faqs' ),
82
  value: props.attributes.show_on_load,
83
+ options: [ {value: '', label: 'No'}, {value: 'Yes', label: 'Yes'} ],
84
  onChange: ( value ) => { props.setAttributes( { show_on_load: value } ); },
85
  } )
86
  ),
87
  );
88
+ returnString.push( el( ServerSideRender, {
89
+ block: 'ultimate-faqs/ewd-ufaq-search-block',
90
+ } ) );
91
  return returnString;
92
  },
93
 
97
  } );
98
 
99
  registerBlockType( 'ultimate-faqs/ewd-ufaq-submit-faq-block', {
100
+ title: Localize( 'Submit FAQ', 'ultimate-faqs' ),
101
  icon: 'editor-help',
102
  category: 'ewd-ufaq-blocks',
103
  attributes: {
105
 
106
  edit: function( props ) {
107
  var returnString = [];
108
+ returnString.push( el( ServerSideRender, {
109
+ block: 'ultimate-faqs/ewd-ufaq-submit-faq-block',
110
+ } ) );
111
  return returnString;
112
  },
113
 
117
  } );
118
 
119
  registerBlockType( 'ultimate-faqs/ewd-ufaq-recent-faqs-block', {
120
+ title: Localize( 'Recent FAQs', 'ultimate-faqs' ),
121
  icon: 'editor-help',
122
  category: 'ewd-ufaq-blocks',
123
  attributes: {
124
+ post_count: {
125
+ type: 'string',
126
+ default: -1
127
+ },
128
  },
129
 
130
  edit: function( props ) {
132
  returnString.push(
133
  el( InspectorControls, {},
134
  el( TextControl, {
135
+ type: 'number',
136
+ label: Localize( 'Number of FAQs', 'ultimate-faqs' ),
137
  value: props.attributes.post_count,
138
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
139
  } )
140
  ),
141
  );
142
+ returnString.push( el( ServerSideRender, {
143
+ block: 'ultimate-faqs/ewd-ufaq-recent-faqs-block',
144
+ attributes: props.attributes
145
+ } ) );
146
  return returnString;
147
  },
148
 
152
  } );
153
 
154
  registerBlockType( 'ultimate-faqs/ewd-ufaq-popular-faqs-block', {
155
+ title: Localize( 'Popular FAQs', 'ultimate-faqs' ),
156
  icon: 'editor-help',
157
  category: 'ewd-ufaq-blocks',
158
  attributes: {
159
+ post_count: {
160
+ type: 'string',
161
+ default: -1
162
+ },
163
  },
164
 
165
  edit: function( props ) {
167
  returnString.push(
168
  el( InspectorControls, {},
169
  el( TextControl, {
170
+ type: 'number',
171
+ label: Localize( 'Number of FAQs', 'ultimate-faqs' ),
172
  value: props.attributes.post_count,
173
  onChange: ( value ) => { props.setAttributes( { post_count: value } ); },
174
  } )
175
  ),
176
  );
177
+ returnString.push( el( ServerSideRender, {
178
+ block: 'ultimate-faqs/ewd-ufaq-popular-faqs-block',
179
+ attributes: props.attributes
180
+ } ) );
181
  return returnString;
182
  },
183
 
includes/Blocks.class.php CHANGED
@@ -29,7 +29,8 @@ class ewdufaqBlocks {
29
  $args = array(
30
  'attributes' => array(
31
  'post_count' => array(
32
- 'type' => 'integer',
 
33
  ),
34
  'include_category' => array(
35
  'type' => 'string',
@@ -38,8 +39,6 @@ class ewdufaqBlocks {
38
  'type' => 'string',
39
  ),
40
  ),
41
- 'editor_script' => 'ewd-ufaq-blocks-js',
42
- 'editor_style' => 'ewd-ufaq-blocks-css',
43
  'render_callback' => 'ewd_ufaq_faqs_shortcode',
44
  );
45
 
@@ -48,11 +47,10 @@ class ewdufaqBlocks {
48
  $args = array(
49
  'attributes' => array(
50
  'post_count' => array(
51
- 'type' => 'integer',
 
52
  ),
53
  ),
54
- 'editor_script' => 'ewd-ufaq-blocks-js',
55
- 'editor_style' => 'ewd-ufaq-blocks-css',
56
  'render_callback' => 'ewd_ufaq_recent_faqs_shortcode',
57
  );
58
 
@@ -61,11 +59,10 @@ class ewdufaqBlocks {
61
  $args = array(
62
  'attributes' => array(
63
  'post_count' => array(
64
- 'type' => 'integer',
 
65
  ),
66
  ),
67
- 'editor_script' => 'ewd-ufaq-blocks-js',
68
- 'editor_style' => 'ewd-ufaq-blocks-css',
69
  'render_callback' => 'ewd_ufaq_popular_faqs_shortcode',
70
  );
71
 
@@ -73,8 +70,8 @@ class ewdufaqBlocks {
73
 
74
  $args = array(
75
  'attributes' => array(
76
- 'post_count' => array(
77
- 'type' => 'integer',
78
  ),
79
  'include_category' => array(
80
  'type' => 'string',
@@ -83,22 +80,35 @@ class ewdufaqBlocks {
83
  'type' => 'string',
84
  ),
85
  ),
86
- 'editor_script' => 'ewd-ufaq-blocks-js',
87
- 'editor_style' => 'ewd-ufaq-blocks-css',
88
  'render_callback' => 'ewd_ufaq_search_faqs_shortcode',
89
  );
90
 
91
  register_block_type( 'ultimate-faqs/ewd-ufaq-search-block', $args );
92
 
93
  $args = array(
94
- 'editor_script' => 'ewd-ufaq-blocks-js',
95
- 'editor_style' => 'ewd-ufaq-blocks-css',
96
  'render_callback' => 'ewd_ufaq_submit_faq_shortcode',
97
  );
98
 
99
  register_block_type( 'ultimate-faqs/ewd-ufaq-submit-faq-block', $args );
 
 
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  /**
103
  * Create a new category of blocks to hold our block
104
  * @since 2.0.0
@@ -119,8 +129,9 @@ class ewdufaqBlocks {
119
  */
120
  public function enqueue_assets() {
121
 
122
- wp_register_script( 'ewd-ufaq-blocks-js', EWD_UFAQ_PLUGIN_URL . '/assets/js/ewd-ufaq-blocks.js', array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor' ), EWD_UFAQ_VERSION );
123
  wp_register_style( 'ewd-ufaq-blocks-css', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq-blocks.css', array( 'wp-edit-blocks' ), EWD_UFAQ_VERSION );
 
124
  }
125
  }
126
 
29
  $args = array(
30
  'attributes' => array(
31
  'post_count' => array(
32
+ 'type' => 'string',
33
+ 'default' => -1
34
  ),
35
  'include_category' => array(
36
  'type' => 'string',
39
  'type' => 'string',
40
  ),
41
  ),
 
 
42
  'render_callback' => 'ewd_ufaq_faqs_shortcode',
43
  );
44
 
47
  $args = array(
48
  'attributes' => array(
49
  'post_count' => array(
50
+ 'type' => 'string',
51
+ 'default' => -1
52
  ),
53
  ),
 
 
54
  'render_callback' => 'ewd_ufaq_recent_faqs_shortcode',
55
  );
56
 
59
  $args = array(
60
  'attributes' => array(
61
  'post_count' => array(
62
+ 'type' => 'string',
63
+ 'default' => -1
64
  ),
65
  ),
 
 
66
  'render_callback' => 'ewd_ufaq_popular_faqs_shortcode',
67
  );
68
 
70
 
71
  $args = array(
72
  'attributes' => array(
73
+ 'show_on_load' => array(
74
+ 'type' => 'string',
75
  ),
76
  'include_category' => array(
77
  'type' => 'string',
80
  'type' => 'string',
81
  ),
82
  ),
 
 
83
  'render_callback' => 'ewd_ufaq_search_faqs_shortcode',
84
  );
85
 
86
  register_block_type( 'ultimate-faqs/ewd-ufaq-search-block', $args );
87
 
88
  $args = array(
 
 
89
  'render_callback' => 'ewd_ufaq_submit_faq_shortcode',
90
  );
91
 
92
  register_block_type( 'ultimate-faqs/ewd-ufaq-submit-faq-block', $args );
93
+
94
+ add_action( 'current_screen', array( $this, 'localize_data' ) );
95
  }
96
 
97
+ /**
98
+ * Conditionally enqueue assets and perform any necessary data localization for use in block parameters
99
+ * @since 2.1.13
100
+ */
101
+ public function localize_data() {
102
+
103
+ $screen = get_current_screen();
104
+
105
+ if ( ! $screen->is_block_editor and $screen->id != 'widgets' ) { return; }
106
+
107
+ wp_enqueue_style( 'ewd-ufaq-css' );
108
+ wp_enqueue_style( 'ewd-ufaq-blocks-css' );
109
+ wp_enqueue_script( 'ewd-ufaq-blocks-js' );
110
+ }
111
+
112
  /**
113
  * Create a new category of blocks to hold our block
114
  * @since 2.0.0
129
  */
130
  public function enqueue_assets() {
131
 
132
+ wp_register_style( 'ewd-ufaq-css', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq.css', EWD_UFAQ_VERSION );
133
  wp_register_style( 'ewd-ufaq-blocks-css', EWD_UFAQ_PLUGIN_URL . '/assets/css/ewd-ufaq-blocks.css', array( 'wp-edit-blocks' ), EWD_UFAQ_VERSION );
134
+ wp_register_script( 'ewd-ufaq-blocks-js', EWD_UFAQ_PLUGIN_URL . '/assets/js/ewd-ufaq-blocks.js', array( 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wp-server-side-render' ), EWD_UFAQ_VERSION );
135
  }
136
  }
137
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Rustaurius, EtoileWebDesign
3
  Tags: faq, faqs, accordion, woocommerce faq, gutenberg faq, faq block
4
  Requires at least: 5.0
5
  Tested up to: 5.9
6
- Stable tag: 2.1.12
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -267,6 +267,9 @@ Video 3 - FAQs Ordering
267
 
268
  == Changelog ==
269
 
 
 
 
270
  = 2.1.12 (2022-05-04) =
271
  - Added a setting to choose/set an FAQ page (as an alternative option to manually putting the block or shortcode on a page).
272
  - Implemented an option to highlight the search term in the results.
3
  Tags: faq, faqs, accordion, woocommerce faq, gutenberg faq, faq block
4
  Requires at least: 5.0
5
  Tested up to: 5.9
6
+ Stable tag: 2.1.13
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
267
 
268
  == Changelog ==
269
 
270
+ = 2.1.13 (2022-05-17) =
271
+ - Added previews for Gutenberg blocks (i.e. when, on the page edit screen, you add the block, it will show a preview).
272
+
273
  = 2.1.12 (2022-05-04) =
274
  - Added a setting to choose/set an FAQ page (as an alternative option to manually putting the block or shortcode on a page).
275
  - Implemented an option to highlight the search term in the results.
ultimate-faqs.php CHANGED
@@ -6,9 +6,9 @@ Description: FAQ and accordion plugin with easy to use Gutenberg blocks, shortco
6
  Author URI: https://www.etoilewebdesign.com/
7
  Terms and Conditions: https://www.etoilewebdesign.com/plugin-terms-and-conditions/
8
  Text Domain: ultimate-faqs
9
- Version: 2.1.12
10
  WC requires at least: 3.0
11
- WC tested up to: 6.4
12
  */
13
 
14
  if ( ! defined( 'ABSPATH' ) )
@@ -46,7 +46,7 @@ class ewdufaqInit {
46
  define( 'EWD_UFAQ_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
47
  define( 'EWD_UFAQ_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
48
  define( 'EWD_UFAQ_TEMPLATE_DIR', 'ewd-ufaq-templates' );
49
- define( 'EWD_UFAQ_VERSION', '2.1.12' );
50
 
51
  define( 'EWD_UFAQ_FAQ_POST_TYPE', 'ufaq' );
52
  define( 'EWD_UFAQ_FAQ_CATEGORY_TAXONOMY', 'ufaq-category' );
6
  Author URI: https://www.etoilewebdesign.com/
7
  Terms and Conditions: https://www.etoilewebdesign.com/plugin-terms-and-conditions/
8
  Text Domain: ultimate-faqs
9
+ Version: 2.1.13
10
  WC requires at least: 3.0
11
+ WC tested up to: 6.5
12
  */
13
 
14
  if ( ! defined( 'ABSPATH' ) )
46
  define( 'EWD_UFAQ_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
47
  define( 'EWD_UFAQ_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
48
  define( 'EWD_UFAQ_TEMPLATE_DIR', 'ewd-ufaq-templates' );
49
+ define( 'EWD_UFAQ_VERSION', '2.1.13' );
50
 
51
  define( 'EWD_UFAQ_FAQ_POST_TYPE', 'ufaq' );
52
  define( 'EWD_UFAQ_FAQ_CATEGORY_TAXONOMY', 'ufaq-category' );