Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafasoufi committed Apr 8, 2024
2 parents 63877a5 + 278557d commit c263034
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
= v1.0.2 =
* Improvement: Enhanced script loader tags for better performance.
* Improvement: Prevented direct access to PHP files to enhance application security.
* Refactoring: Prefixed settings attributes to avoid conflicts and ensure uniqueness.
* Improvement: Moved `app.js` to a local directory for improved load times.

= v1.0.1 =
* Addition: Added option Opening Style.
* Improvement: Implemented minor enhancements.
Expand Down
4 changes: 3 additions & 1 deletion feedbackbird.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: VeronaLabs
* Author URI: https://veronalabs.com
* Text Domain: feedbackbird
* Version: 1.0.1
* Version: 1.0.2
* License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Requires at least: 4.0
Expand All @@ -15,6 +15,8 @@
* @package FeedbackBird
*/

if (!defined('ABSPATH')) exit;

use FeedbackBird\Assets\EnqueueScripts;
use FeedbackBird\Services\Admin\SettingsPage;

Expand Down
10 changes: 6 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: feedback, user engagement, widget, management
Requires at least: 4.5
Tested up to: 6.5
Requires PHP: 5.6
Stable tag: 1.0.1
Stable tag: 1.0.2
Requires at least: 4.0
License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -47,9 +47,11 @@ FeedbackBird is designed to be compatible with most WordPress themes. The widget

== Changelog ==

= v1.0.1 =
* Addition: Added option Opening Style.
* Improvement: Implemented minor enhancements.
= v1.0.2 =
* Improvement: Enhanced script loader tags for better performance.
* Improvement: Prevented direct access to PHP files to enhance application security.
* Refactoring: Prefixed settings attributes to avoid conflicts and ensure uniqueness.
* Improvement: Moved `app.js` to a local directory for improved load times.

[See changelog for all versions](https://raw.githubusercontent.com/feedbackbird/plugin-wordpress/master/CHANGELOG.md).

Expand Down
16 changes: 9 additions & 7 deletions src/Services/Admin/SettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace FeedbackBird\Services\Admin;

if (!defined('ABSPATH')) exit;

class SettingsPage
{
private $feedbackbird_options;
Expand Down Expand Up @@ -58,55 +60,55 @@ public function registerFields()
);

add_settings_field(
'widget_status', // id
'feedbackbird_widget_status', // id
'Status', // title
array($this, 'widget_status_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'uid', // id
'feedbackbird_uid', // id
'Account UID', // title
array($this, 'uid_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'widget_position', // id
'feedbackbird_widget_position', // id
'Widget Position', // title
array($this, 'widget_position_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'widget_opening_style', // id
'feedbackbird_widget_opening_style', // id
'Widget Opening Style', // title
array($this, 'widget_opening_style_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'widget_color', // id
'feedbackbird_widget_color', // id
'Widget Color', // title
array($this, 'widget_color_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'button_label', // id
'feedbackbird_button_label', // id
'Button Label', // title
array($this, 'button_label_callback'), // callback
'feedbackbird-admin', // page
'feedbackbird_setting_section' // section
);

add_settings_field(
'widget_subtitle', // id
'feedbackbird_widget_subtitle', // id
'Widget Subtitle', // title
array($this, 'widget_subtitle_callback'), // callback
'feedbackbird-admin', // page
Expand Down
17 changes: 11 additions & 6 deletions src/Services/Assets/EnqueueScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@

use FeedbackBird\Utils\Option;

if (!defined('ABSPATH')) exit;

class EnqueueScripts
{
public function init()
{
add_action('wp_enqueue_scripts', [$this, 'registerWidgetScripts']);
add_filter('script_loader_tag', array($this, 'scriptLoaderTags'), 10, 3);
}

public function registerWidgetScripts()
{
if (Option::get('widget_status')) {
wp_enqueue_script('feedbackbird-widget', sprintf('%s/assets/js/app.js?uid=%s', esc_url(FEEDBACKBIRD_URL), Option::get('uid')), array(), '1.1.9', true);
wp_add_inline_script('feedbackbird-widget', sprintf('var feedbackBirdObject = %s;', wp_json_encode($this->generateObjects())));
}
}

add_filter('script_loader_tag', function ($tag, $handle, $src) {
if ('feedbackbird-widget' === $handle) {
return preg_replace('/^<script /i', '<script type="module" crossorigin="crossorigin" ', $tag);
}
return $tag;
}, 10, 3);
public function scriptLoaderTags($tag, $handle, $src)
{
if ('feedbackbird-widget' === $handle) {
return preg_replace('/^<script /i', '<script type="module" crossorigin="crossorigin" ', $tag);
}

return $tag;
}

private function generateObjects()
Expand Down
2 changes: 2 additions & 0 deletions src/Utils/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace FeedbackBird\Utils;

if (!defined('ABSPATH')) exit;

class Option
{
private static $optionName = 'feedbackbird';
Expand Down

0 comments on commit c263034

Please sign in to comment.