diff --git a/.browserslistrc b/.browserslistrc
new file mode 100644
index 0000000..d90e7e8
--- /dev/null
+++ b/.browserslistrc
@@ -0,0 +1,5 @@
+# https://github.com/browserslist/browserslist#readme
+
+>= 1%
+last 2 major version
+not dead
diff --git a/.distignore b/.distignore
new file mode 100644
index 0000000..d7e8069
--- /dev/null
+++ b/.distignore
@@ -0,0 +1,23 @@
+.browserslistrc
+.editorconfig
+.eslintrc
+.distignore
+.git
+.github
+.gitignore
+.node-version
+.stylelintrc.json
+.wordpress-org
+.wp-env.json
+node_modules
+composer.lock
+package-lock.json
+phpcs.ruleset.xml
+phpunit.xml.dist
+README.md
+webpack.config.js
+wordpress
+bin
+tests
+anyway-feedback.php.bak
+readme.txt.bak
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..3c63ebf
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,25 @@
+# This file is for unifying the coding style for different editors and IDEs
+# editorconfig.org
+
+# WordPress Coding Standards
+# https://make.wordpress.org/core/handbook/coding-standards/
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = tab
+tab_width = 4
+
+[*.yml]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
+
+[{*.txt,wp-config-sample.php}]
+end_of_line = crlf
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..5b31696
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,39 @@
+{
+ "parser": "@babel/eslint-parser",
+ "env": {
+ "browser": true,
+ "jquery": true
+ },
+ "globals": {
+ "wp": false,
+ "jQuery": false,
+ "ga": false
+ },
+ "extends": [
+ "plugin:@wordpress/eslint-plugin/recommended"
+ ],
+ "ignorePatterns": ["**/*/*.min.js", "**/*/js.cookie.js"],
+ "rules": {
+ "no-alert": "off",
+ "prettier/prettier": "off",
+ "object-shorthand": "off",
+ "jsdoc/require-jsdoc": "off",
+ "jsdoc/no-undefined-types": "off",
+ "react/react-in-jsx-scope": "off",
+ "react/jsx-sort-props": "off",
+ "jsdoc/check-tag-names": "off",
+ "import/order": "off",
+ "no-prototype-builtins": "off",
+ "object-curly-newline": "off",
+ "object-property-newline": "off",
+ "yoda": "off",
+ "strict": "off",
+ "@wordpress/valid-sprintf": "off",
+ "camelcase": "off"
+ },
+ "settings": {
+ "react": {
+ "version": "16.9.0"
+ }
+ }
+}
diff --git a/.github/workflows/wordpress.yml b/.github/workflows/wordpress.yml
new file mode 100644
index 0000000..329c464
--- /dev/null
+++ b/.github/workflows/wordpress.yml
@@ -0,0 +1,104 @@
+name: Deploy Plugin
+
+on:
+ push:
+ branches:
+ - master
+ tags:
+ - '*'
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ phpcs:
+ uses: tarosky/workflows/.github/workflows/phpcs.yml@main
+ with:
+ version: 8.0
+
+ phplint:
+ uses: tarosky/workflows/.github/workflows/phplint.yml@main
+
+ assets:
+ name: Assets Test
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@main
+
+ - name: Install Node
+ uses: actions/setup-node@v3
+ with:
+ node-version: '16'
+
+ - name: Install NPM Packages
+ run: npm install
+
+ - name: Check JS & CSS syntax
+ run: npm run lint
+
+ release:
+ name: Deploy WordPress.org
+ needs: [ phpcs, phplint, assets ]
+ if: contains(github.ref, 'tags/')
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@main
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: 7.2
+ tools: composer
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Install Node
+ uses: actions/setup-node@v3
+ with:
+ node-version: '16'
+
+ - name: Build Plugin
+ run: |
+ composer install --prefer-dist --no-dev
+ npm install
+ npm run package
+
+ - name: Generate readme.txt
+ uses: tarosky/workflows/actions/wp-readme@main
+
+ - name: Versioning
+ uses: tarosky/workflows/actions/versioning@main
+ with:
+ version: ${{ github.ref }}
+ files: readme.txt,anyway-feedback.php
+
+ - name: Deploy to WordPress Directory
+ id: deploy
+ uses: 10up/action-wordpress-plugin-deploy@stable
+ with:
+ generate-zip: true
+ env:
+ SVN_USERNAME: ${{ secrets.WP_ORG_USERNAME }}
+ SVN_PASSWORD: ${{ secrets.WP_ORG_PASSWORD }}
+
+ - name: Create Release
+ id: create_release
+ uses: actions/create-release@v1.0.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ tag_name: ${{ github.ref }}
+ release_name: Release ${{ github.ref }}
+ draft: false
+ prerelease: false
+
+ - name: Upload release asset
+ uses: actions/upload-release-asset@v1.0.1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: ${{ github.workspace }}/${{ github.event.repository.name }}.zip
+ asset_name: ${{ github.event.repository.name }}.zip
+ asset_content_type: application/zip
diff --git a/.gitignore b/.gitignore
index d174df5..50ffa3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,11 @@
.DS_Store
-.svn
\ No newline at end of file
+.svn
+/vendor/
+/node_modules/
+/assets/css/
+/assets/js/*.min.js
+/assets/js/js.cookie.js
+/assets/vendor/
+/dist/
+readme.txt
+composer.lock
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index ba48a37..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "assets/vendor/jquery.cookie"]
- path = assets/vendor/jquery.cookie
- url = https://github.com/carhartl/jquery-cookie.git
diff --git a/.stylelintrc.json b/.stylelintrc.json
new file mode 100644
index 0000000..cd2f75e
--- /dev/null
+++ b/.stylelintrc.json
@@ -0,0 +1,17 @@
+{
+ "extends": [
+ "stylelint-config-wordpress/scss"
+ ],
+ "rules": {
+ "value-keyword-case": [ "lower", {
+ "ignoreProperties": [ "font-family" ]
+ } ],
+ "color-named": null,
+ "number-leading-zero": null,
+ "rule-empty-line-before": null,
+ "declaration-property-unit-whitelist": null,
+ "selector-class-pattern": null,
+ "at-rule-empty-line-before": null,
+ "no-descending-specificity": null
+ }
+}
diff --git a/.wordpress-org/banner-772x250.jpg b/.wordpress-org/banner-772x250.jpg
new file mode 100644
index 0000000..09dbaa6
Binary files /dev/null and b/.wordpress-org/banner-772x250.jpg differ
diff --git a/.wordpress-org/icon-128x128.png b/.wordpress-org/icon-128x128.png
new file mode 100644
index 0000000..b9b6c6c
Binary files /dev/null and b/.wordpress-org/icon-128x128.png differ
diff --git a/.wordpress-org/icon-256x256.png b/.wordpress-org/icon-256x256.png
new file mode 100644
index 0000000..24567bf
Binary files /dev/null and b/.wordpress-org/icon-256x256.png differ
diff --git a/screenshot-1.png b/.wordpress-org/screenshot-1.png
similarity index 100%
rename from screenshot-1.png
rename to .wordpress-org/screenshot-1.png
diff --git a/screenshot-2.png b/.wordpress-org/screenshot-2.png
similarity index 100%
rename from screenshot-2.png
rename to .wordpress-org/screenshot-2.png
diff --git a/screenshot-3.png b/.wordpress-org/screenshot-3.png
similarity index 100%
rename from screenshot-3.png
rename to .wordpress-org/screenshot-3.png
diff --git a/.wp-env.json b/.wp-env.json
new file mode 100644
index 0000000..af08aa0
--- /dev/null
+++ b/.wp-env.json
@@ -0,0 +1,6 @@
+{
+ "plugins": [ "." ],
+ "themes": [
+ "https://downloads.wordpress.org/theme/twentytwenty.latest-stable.zip"
+ ]
+}
diff --git a/readme.md b/README.md
similarity index 89%
rename from readme.md
rename to README.md
index 32533e5..e1b03d7 100644
--- a/readme.md
+++ b/README.md
@@ -1,11 +1,13 @@
# Anyway Feedback
-Contributors: Takahashi_Fumiki
+
+Contributors: Takahashi_Fumiki,hametuha
Tags: feedback, analytics
-Requires at least: 3.8
-Tested up to: 4.1-alpha
-Stable tag: 1.0.1
+Requires at least: 5.9
+Requires PHP: 7.4
+Tested up to: 6.4
+Stable tag: nightly
-This plugin enable users to send feedback with single click. This may support you to analyze your user's opinion. Works like Facebook's help center.
+This plugin enable users to send feedback with single click. This may support you to analyze your user's opinion. Works as a help center for your site.
## Description
@@ -60,7 +62,7 @@ There are currently 2 ways. 1st is a feedback controller which displays number o
### 1.0
-* Requires PHP 5.3 and over. Name space is so cool! Template tags have backward compatibility.
+* Requires PHP 5.4 and over. Name space is so cool! Template tags have backward compatibility.
* Quit using session. Vote history will be stored in Cookie.
* Refine admin screen.
* Fix some style sheet.
diff --git a/anyway-feedback.php b/anyway-feedback.php
index 3c02b92..f5bf6a6 100644
--- a/anyway-feedback.php
+++ b/anyway-feedback.php
@@ -1,11 +1,11 @@
{$message}
HTML;
}
-
-/**
- * Just define for translation.
- *
- * @ignore
- * @internal
- * @global Anyway_Feedback $afb
- * @return void
- */
-function _afb_translation() {
- global $afb;
- $afb->_('Oops, Anyway Feedback doesn\'t work. You PHP Version is %s but PHP 5.3 and over required.');
- $afb->_( "Help to assemble simple feedback(negative or positive) and get statics of them." );
-}
diff --git a/app/Admin/Screen.php b/app/Admin/Screen.php
index 1c9c96f..5e65ba1 100644
--- a/app/Admin/Screen.php
+++ b/app/Admin/Screen.php
@@ -3,7 +3,6 @@
namespace AFB\Admin;
-use AFB\Helper\i18n;
use AFB\Pattern\Controller;
/**
@@ -11,15 +10,7 @@
*
* @package AFB
*/
-class Screen extends Controller
-{
-
- /**
- * Session key
- *
- * @var string
- */
- private $session_key = 'afb_session';
+class Screen extends Controller {
/**
* Constructor
@@ -27,67 +18,52 @@ class Screen extends Controller
* @param array $arguments
*/
protected function __construct( array $arguments = array() ) {
- add_action('admin_menu', array($this, 'admin_menu'));
- add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
- add_action('admin_init', array($this, 'admin_init'));
- add_action('admin_notices', array($this, 'admin_notices'));
- add_filter('manage_edit-comments_columns', array($this, 'comment_columns_name'));
- add_action('manage_comments_custom_column', array($this, 'comment_columns'), 10, 2);
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
+ add_action( 'wp_ajax_afb_chart', array( $this, 'ajax' ) );
+ add_filter( 'manage_edit-comments_columns', array( $this, 'comment_columns_name' ) );
+ add_action( 'manage_comments_custom_column', array( $this, 'comment_columns' ), 10, 2 );
}
/**
* Add admin menu
*/
- public function admin_menu(){
+ public function admin_menu() {
+ // Add settings page.
add_options_page(
- $this->i18n->_("Anyway Feedback Option: "),
- $this->i18n->_('Anyway Feedback'),
+ __( 'Anyway Feedback Option: ', 'anyway-feedback' ),
+ __( 'Anyway Feedback', 'anyway-feedback' ),
'manage_options',
- "anyway-feedback",
- array($this, "render_admin")
+ 'anyway-feedback',
+ array( $this, 'render_admin' )
);
- foreach( $this->option['post_types'] as $post_type ){
+ // Add stats.
+ foreach ( $this->option['post_types'] as $post_type ) {
$page = 'edit.php';
- if( 'post' != $post_type ){
- $page .= '?post_type='.$post_type;
+ if ( 'post' !== $post_type ) {
+ $page .= '?post_type=' . $post_type;
}
- $object = get_post_type_object($post_type);
- add_submenu_page($page, sprintf($this->i18n->_('Feedback Statistic of %s'), $object->labels->name), $this->i18n->_('Feedback Statistic'), 'edit_posts', 'anyway-feedback-static-'.$post_type, array($this, 'render_static'));
+ $object = get_post_type_object( $post_type );
+ // translators: %s is post type name.
+ add_submenu_page( $page, sprintf( __( 'Feedback Statistic of %s', 'anyway-feedback' ), $object->labels->name ), __( 'Feedback Statistic', 'anyway-feedback' ), 'edit_posts', 'anyway-feedback-static-' . $post_type, array( $this, 'render_static' ) );
}
}
- /**
- * Render admin screen
- */
- public function render_admin(){
- $this->load_template('admin.php');
- }
-
- /**
- * Render static screen
- */
- public function render_static(){
- $post_type = get_post_type_object(str_replace('anyway-feedback-static-', '', $this->input->get('page')));
- $this->load_template('statistic.php', array(
- 'post_type' => $post_type,
- 'table' => new Table(array('post_type' => $post_type->name)),
- ));
- }
-
/**
* Returns setting URL
*
* @param string $view
*
- * @return bool
+ * @return string
*/
- public function setting_url($view = ''){
- $base = admin_url('options-general.php?page=anyway-feedback');
- if( $view ){
- $base .= '&view='.$view;
+ public function setting_url( $view = '' ) {
+ $base = admin_url( 'options-general.php?page=anyway-feedback' );
+ if ( $view ) {
+ $base .= '&view=' . $view;
}
- return esc_url($base);
+ return esc_url( $base );
}
/**
@@ -96,15 +72,16 @@ public function setting_url($view = ''){
* @param string $name
* @param array $args
*/
- public function load_template($name, $args = array()){
- $path = $this->dir.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$name;
- if( file_exists($path) ){
- if( !empty($args) ){
- extract($args);
+ public function load_template( $name, $args = array() ) {
+ $path = $this->dir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $name;
+ if ( file_exists( $path ) ) {
+ if ( ! empty( $args ) ) {
+ // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
+ extract( $args );
}
include $path;
- }else{
- printf('', $this->i18n->_('Template file doesn\'t exist. Please check whether install process is valid.'));
+ } else {
+ printf( '', __( 'Template file doesn\'t exist. Please check whether install process is valid.', 'anyway-feedback' ) );
}
}
@@ -113,38 +90,40 @@ public function load_template($name, $args = array()){
*
* @param string $page
*/
- public function admin_enqueue_scripts($page){
- if( ($is_statistic = (false !== strpos($page, 'anyway-feedback-static')))
- || 'settings_page_anyway-feedback' === $page
- || 'edit-comments.php' === $page
- ){
- $deps = array('jquery');
- if( $is_statistic ){
- wp_register_script('google-chart-api', 'https://www.google.com/jsapi', null, null);
+ public function admin_enqueue_scripts( $page ) {
+ $is_statistic = ( false !== strpos( $page, 'anyway-feedback-static' ) );
+ if (
+ $is_statistic
+ || 'settings_page_anyway-feedback' === $page
+ || 'edit-comments.php' === $page
+ ) {
+ $deps = array( 'jquery' );
+ if ( $is_statistic ) {
+ wp_register_script( 'google-chart-api', 'https://www.google.com/jsapi', null, null );
$deps[] = 'google-chart-api';
}
// Main Style sheet
wp_enqueue_style(
'afb-admin',
- $this->assets_url("css/admin-style.css"),
+ $this->url . 'dist/css/admin-style.css',
null,
$this->version,
'screen'
);
// Script
wp_enqueue_script(
- "afb-util",
- $this->assets_url('js/admin-script.js', true),
+ 'afb-util',
+ $this->url . 'dist/js/admin-script.js',
$deps,
$this->version,
true
);
- if( $is_statistic ){
+ if ( $is_statistic ) {
wp_localize_script('afb-util', 'AFB', array(
- 'pieTitle' => $this->i18n->_('Feedback Ratio'),
- 'piePositive' => $this->i18n->_('Positive'),
- 'pieNegative' => $this->i18n->_('Negative'),
- 'noData' => $this->i18n->_('No data'),
+ 'pieTitle' => __( 'Feedback Ratio', 'anyway-feedback' ),
+ 'piePositive' => __( 'Positive', 'anyway-feedback' ),
+ 'pieNegative' => __( 'Negative', 'anyway-feedback' ),
+ 'noData' => __( 'No data', 'anyway-feedback' ),
));
}
}
@@ -153,67 +132,134 @@ public function admin_enqueue_scripts($page){
/**
* Update option
*/
- public function admin_init(){
- if( !defined('DOING_AJAX') || !DOING_AJAX ){
+ public function admin_init() {
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
+ return;
+ }
+ // Refresh option.
+ $this->refresh_option();
+ // default setting.
+ add_settings_section( 'afb-default-section', __( 'Feedback Setting', 'anyway-feedback' ), function() {
+ // Register something.
+ }, 'anyway-feedback' );
+ add_settings_section( 'afb-appearance-section', __( 'Appearance', 'anyway-feedback' ), function() {
+ // Register something.
+ }, 'anyway-feedback' );
+ add_settings_section( 'afb-option-section', __( 'Option', 'anyway-feedback' ), function() {
+ // Register something.
+ }, 'anyway-feedback' );
+ $settings = [
+ 'post_types' => [ __( 'Post Types', 'anyway-feedback' ), 'default', [] ],
+ 'comment' => [
+ __( 'Comment', 'anyway-feedback' ),
+ 'default',
+ [
+ '' => __( 'Not supported', 'anyway-feedback' ),
+ 1 => __( 'Allow feedback for comments', 'anyway-feedback' ),
+ ],
+ ],
+ 'style' => [
+ __( 'Controller Appearance', 'anyway-feedback' ),
+ 'appearance',
+ [
+ '' => __( 'No style', 'anyway-feedback' ),
+ 1 => __( 'Plugin Default', 'anyway-feedback' ),
+ ],
+ ],
+ 'hide_default_controller' => [ __( 'Hide default feedback controller', 'anyway-feedback' ), 'appearance', [] ],
+ 'controller' => [ __( 'Custom markup', 'anyway-feedback' ), 'appearance', [] ],
+ 'ga' => [
+ __( 'Google Analytics Integration', 'anyway-feedback' ),
+ 'option',
+ [
+ '' => __( 'Not Active', 'anyway-feedback' ),
+ 1 => __( 'Track Event', 'anyway-feedback' ),
+ ],
+ ],
+ ];
+ foreach ( $settings as $key => list( $label, $section, $options ) ) {
+ add_settings_field( 'afb_' . $key, $label, function() use ( $key, $options ) {
+ $option_key = 'afb_' . $key;
+ $value = get_option( $option_key );
+ switch ( $key ) {
+ case 'post_types':
+ case 'hide_default_controller':
+ $value = (array) $value;
+ foreach ( get_post_types( [ 'public' => true ], OBJECT ) as $post_type ) {
+ printf( ' %s ',
+ esc_attr( $option_key ),
+ $post_type->name,
+ checked( in_array( $post_type->name, $value, true ), true, false ),
+ esc_html( $post_type->label )
+ );
+ }
+ break;
+ case 'comment':
+ case 'style':
+ case 'ga':
+ foreach ( $options as $val => $text ) {
+ printf( ' %s ',
+ esc_attr( $option_key ),
+ esc_attr( $val ),
+ checked( $val, $value, false ),
+ esc_html( $text )
+ );
+ }
+ break;
+ case 'controller':
+ printf(
+ '',
+ esc_attr( $option_key ),
+ esc_textarea( $value )
+ );
+ break;
+ }
+ do_action( 'afb_after_setting_field', $key, $value );
+ }, 'anyway-feedback', 'afb-' . $section . '-section' );
+ register_setting( 'anyway-feedback', 'afb_' . $key );
+ }
- // If session doesn't exist, start it.
- if( !session_id() ){
- session_start();
+ // If current user is admin, check table and try update
+ if ( current_user_can( 'update_plugins' ) ) {
+ if ( $this->feedbacks->try_update_db() ) {
+ $message = __( 'Database has been updated.', 'anyway-feedback' );
+ add_action('admin_notices', function() use ( $message ) {
+ printf( '', esc_html( $message ) );
+ });
}
+ }
+ }
- // Check nonce and process form.
- if( $this->input->check_nonce('afb_option', '_afb_nonce') ){
- $new_option = array(
- "style" => intval((bool)$this->input->post('afb_style')),
- "post_types" => (array)$this->input->post('afb_post_types'),
- "hide_default_controller" => (array)$this->input->post('afb_hide_default_controller'),
- "comment" => intval((bool)$this->input->post('afb_comment')),
- "controller" => (string)$this->input->post('afb_text'),
- 'ga' => intval((bool)$this->input->post('afb_ga')),
- );
- update_option('afb_setting', $new_option);
- // Add message
- $_SESSION[$this->session_key] = $this->i18n->_('Option was updated.');
- // Redirect
- wp_safe_redirect($this->setting_url());
- exit;
- }
- // If current user is admin, check table and try update
- if( current_user_can('update_plugins') ){
- if( $this->feedbacks->try_update_db() ){
- $message = $this->i18n->_('Database has been updated.');
- add_action('admin_notices', function() use ($message){
- printf('', esc_html($message));
- });
- }
- }
- }else{
- add_action('wp_ajax_afb_chart', array($this, 'ajax'));
- }
+ /**
+ * Render admin screen
+ */
+ public function render_admin() {
+ $this->load_template( 'admin.php' );
}
/**
- * Process Ajax
+ * Render static screen
*/
- public function ajax(){
- if( $this->input->check_nonce('afb_chart') ){
- $post_type = $this->input->get('post_type');
- $json = array(
- 'ratio' => $this->feedbacks->get_ratio($post_type),
- 'ranking' => $this->feedbacks->get_ranking($post_type),
- );
- wp_send_json($json);
- }
+ public function render_static() {
+ $post_type = get_post_type_object( str_replace( 'anyway-feedback-static-', '', $this->input->get( 'page' ) ) );
+ $this->load_template( 'statistic.php', array(
+ 'post_type' => $post_type,
+ 'table' => new Table( array( 'post_type' => $post_type->name ) ),
+ ) );
}
/**
- * Show update message
+ * Process Ajax
*/
- public function admin_notices(){
- if( isset($_SESSION[$this->session_key]) ){
- printf('', esc_html($_SESSION[$this->session_key]));
- unset($_SESSION[$this->session_key]);
+ public function ajax() {
+ if ( $this->input->check_nonce( 'afb_chart' ) ) {
+ $post_type = $this->input->get( 'post_type' );
+ $json = array(
+ 'ratio' => $this->feedbacks->get_ratio( $post_type ),
+ 'ranking' => $this->feedbacks->get_ranking( $post_type ),
+ );
+ wp_send_json( $json );
}
}
@@ -224,8 +270,8 @@ public function admin_notices(){
*
* @return array
*/
- public function comment_columns_name($columns){
- $columns['feedback'] = $this->i18n->_('Feedback');
+ public function comment_columns_name( $columns ) {
+ $columns['feedback'] = __( 'Feedback', 'anyway-feedback' );
return $columns;
}
@@ -235,16 +281,16 @@ public function comment_columns_name($columns){
* @param string $column
* @param int $comment_id
*/
- public function comment_columns( $column, $comment_id ){
- switch( $column ){
+ public function comment_columns( $column, $comment_id ) {
+ switch ( $column ) {
case 'feedback':
- $feedback = $this->feedbacks->get($comment_id, 'comment');
- if( $feedback ){
- $total = $feedback->positive + $feedback->negative;
- $positive = floor($feedback->positive / $total * 100);
+ $feedback = $this->feedbacks->get( $comment_id, 'comment' );
+ if ( $feedback ) {
+ $total = $feedback->positive + $feedback->negative;
+ $positive = floor( $feedback->positive / $total * 100 );
printf('',
- $positive, $feedback->positive, $feedback->negative);
- }else{
+ $positive, $feedback->positive, $feedback->negative);
+ } else {
echo '
';
}
break;
@@ -254,4 +300,4 @@ public function comment_columns( $column, $comment_id ){
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Admin/Table.php b/app/Admin/Table.php
index 05571b0..8a2ac54 100644
--- a/app/Admin/Table.php
+++ b/app/Admin/Table.php
@@ -1,7 +1,6 @@
post_type = get_post_type_object($args['post_type']);
+ $this->post_type = get_post_type_object( $args['post_type'] );
parent::__construct( array(
- 'singular' => $this->post_type->name,
- 'plural' => $this->post_type->name,
- 'ajax' => false
+ 'singular' => $this->post_type->name,
+ 'plural' => $this->post_type->name,
+ 'ajax' => false,
) );
}
@@ -52,14 +50,14 @@ public function __construct( $args = array() ){
*
* @return array
*/
- public function get_columns(){
+ public function get_columns() {
$columns = array(
- 'title' => $this->i18n->_('Title'),
- 'positive' => $this->i18n->_('Good'),
- 'ratio' => ' ',
- 'negative' => $this->i18n->_('Bad'),
- 'published' => $this->i18n->_('Published'),
- 'updated' => $this->i18n->_('Updated'),
+ 'title' => __( 'Title', 'anyway-feedback' ),
+ 'positive' => __( 'Good', 'anyway-feedback' ),
+ 'ratio' => ' ',
+ 'negative' => __( 'Bad', 'anyway-feedback' ),
+ 'published' => __( 'Published', 'anyway-feedback' ),
+ 'updated' => __( 'Updated', 'anyway-feedback' ),
);
return $columns;
}
@@ -69,13 +67,13 @@ public function get_columns(){
*
* @return array
*/
- public function get_sortable_columns(){
+ public function get_sortable_columns() {
$columns = array(
- 'title' => array('title',false),
- 'positive' => array('positive',false),
- 'negative' => array('negative',false),
- 'published' => array('published',false),
- 'updated' => array('updated',false),
+ 'title' => array( 'title', false ),
+ 'positive' => array( 'positive', false ),
+ 'negative' => array( 'negative', false ),
+ 'published' => array( 'published', false ),
+ 'updated' => array( 'updated', false ),
);
return $columns;
}
@@ -83,7 +81,7 @@ public function get_sortable_columns(){
/**
* Prepare items
*/
- public function prepare_items(){
+ public function prepare_items() {
// Set header
$this->_column_headers = array(
$this->get_columns(),
@@ -93,13 +91,13 @@ public function prepare_items(){
$args = array(
'post_type' => $this->post_type->name,
- 'order' => strtoupper($this->input->get('order')),
- 'orderby' => $this->input->get('orderby'),
- 's' => $this->input->get('s'),
+ 'order' => strtoupper( $this->input->get( 'order' ) ),
+ 'orderby' => $this->input->get( 'orderby' ),
+ 's' => $this->input->get( 's' ),
);
// Get data
- $this->items = $this->feedbacks->search($args, $this->input->get('paged'));
+ $this->items = $this->feedbacks->search( $args, $this->input->get( 'paged' ) );
// Total count
$total_items = $this->feedbacks->total();
@@ -108,7 +106,7 @@ public function prepare_items(){
$this->set_pagination_args( array(
'total_items' => $total_items, //WE have to calculate the total number of items
'per_page' => $this->per_page, //WE have to determine how many items to show on a page
- 'total_pages' => ceil($total_items / $this->per_page) //WE have to calculate the total number of pages
+ 'total_pages' => ceil( $total_items / $this->per_page ), //WE have to calculate the total number of pages
) );
}
@@ -120,61 +118,61 @@ public function prepare_items(){
*
* @return bool|int|mixed|string|void
*/
- public function column_default($item, $column_name){
- switch($column_name){
+ public function column_default( $item, $column_name ) {
+ switch ( $column_name ) {
case 'positive':
case 'negative':
- return number_format($item->{$column_name});
+ return number_format( $item->{$column_name} );
case 'title':
- $title = esc_html($item->post_title).' - ';
- switch( $item->post_status ){
+ $title = esc_html( $item->post_title ) . ' - ';
+ switch ( $item->post_status ) {
case 'publish':
- $title .= sprintf('%s ', __('Published'));
+ $title .= sprintf( '%s ', __( 'Published' ) );
break;
case 'future':
- $title .= sprintf('%s ', __('Future'));
+ $title .= sprintf( '%s ', __( 'Future' ) );
break;
case 'draft':
- $title .= sprintf('%s ', __('Draft'));
+ $title .= sprintf( '%s ', __( 'Draft' ) );
break;
case 'trash':
- $title .= sprintf('%s ', __('Trash'));
+ $title .= sprintf( '%s ', __( 'Trash' ) );
break;
case 'private':
- $title .= sprintf('%s ', __(':Private'));
+ $title .= sprintf( '%s ', __( ':Private' ) );
break;
}
$actions = array(
- 'view' => sprintf('%s ', get_permalink($item->ID), __('View')),
+ 'view' => sprintf( '%s ', get_permalink( $item->ID ), __( 'View' ) ),
);
- if( current_user_can('edit_post', $item->ID) ){
- $actions['edit'] = sprintf('%s ', get_edit_post_link($item->ID), __('Edit'));
+ if ( current_user_can( 'edit_post', $item->ID ) ) {
+ $actions['edit'] = sprintf( '%s ', get_edit_post_link( $item->ID ), __( 'Edit' ) );
}
- $title .= $this->row_actions($actions, false);
+ $title .= $this->row_actions( $actions, false );
return $title;
break;
case 'published':
- $date = mysql2date(get_option('date_format'), $item->post_date);
+ $date = mysql2date( get_option( 'date_format' ), $item->post_date );
return $date;
break;
case 'updated':
- if( $item->updated ){
- return mysql2date(get_option('date_format'), $item->updated);
- }else{
+ if ( $item->updated ) {
+ return mysql2date( get_option( 'date_format' ), $item->updated );
+ } else {
return '---';
}
break;
case 'ratio':
$total = $item->positive + $item->negative;
- if( $total ){
- $positive = floor($item->positive / $total * 100);
- return sprintf('', $positive);
- }else{
+ if ( $total ) {
+ $positive = floor( $item->positive / $total * 100 );
+ return sprintf( '', $positive );
+ } else {
return '
';
}
break;
default:
- return print_r($item, true); //Show the whole array for troubleshooting purposes
+ return print_r( $item, true ); //Show the whole array for troubleshooting purposes
}
}
@@ -195,20 +193,14 @@ protected function get_table_classes() {
*
* @return mixed
*/
- public function __get($name){
- switch( $name ){
+ public function __get( $name ) {
+ switch ( $name ) {
case 'feedbacks':
return FeedBacks::get_instance();
- break;
- case 'i18n':
- return i18n::get_instance();
- break;
case 'input':
return Input::get_instance();
- break;
default:
- return parent::__get($name);
- break;
+ return parent::__get( $name );
}
}
diff --git a/app/Api/ApiFeedback.php b/app/Api/ApiFeedback.php
new file mode 100644
index 0000000..6cb8031
--- /dev/null
+++ b/app/Api/ApiFeedback.php
@@ -0,0 +1,112 @@
+[^/]+)/(?P\d+)/?', [
+ 'methods' => 'POST',
+ 'callback' => [ $this, 'post_feedback' ],
+ 'permission_callback' => [ $this, 'permission_callback' ],
+ 'args' => [
+ 'post_type' => [
+ 'required' => true,
+ 'type' => 'string',
+ 'validate_callback' => function ( $post_type ) {
+ return ( 'comment' === $post_type ) || post_type_exists( $post_type );
+ },
+ ],
+ 'object_id' => [
+ 'required' => true,
+ 'type' => 'integer',
+ 'validate_callback' => function ( $object_id ) {
+ return is_numeric( $object_id ) && 0 < $object_id;
+ },
+ ],
+ 'affirmative' => [
+ 'required' => true,
+ 'type' => 'integer',
+ 'validate_callback' => function ( $affirmative ) {
+ return in_array( $affirmative, [ 1, 0 ], true );
+ },
+ ],
+ ],
+ ] );
+ }
+
+ /**
+ * Is user allowed to post feedback?
+ *
+ * @param \WP_REST_Request $request Request object.
+ * @return bool|\WP_Error
+ */
+ public function permission_callback( $request ) {
+ if ( $this->does_current_user_posted( $request->get_param( 'post_type' ), $request->get_param( 'object_id' ) ) ) {
+ return new \WP_Error( 'afb_already_voted', __( 'Sorry, but you have already voted.', 'anyway-feedback' ), [
+ 'status' => 403,
+ ] );
+ }
+ return true;
+ }
+
+ /**
+ * Handle feedback request.
+ *
+ * @param \WP_REST_Request $request Request object.
+ * @return \WP_Error|\WP_REST_Response
+ */
+ public function post_feedback( \WP_REST_Request $request ) {
+ $post_type = $request->get_param( 'post_type' );
+ $object_id = $request->get_param( 'object_id' );
+ $post_type_name = 'comment' === $post_type ? __( 'Comment', 'anyway-feedback' ) : get_post_type_object( $post_type )->labels->singular_name;
+
+ // Feedback request is valid.
+ $affirmative = (bool) $request->get_param( 'affirmative' );
+ if ( ! $this->feedbacks->update( $object_id, $post_type, $affirmative ) ) {
+ if ( ! $this->feedbacks->add( $object_id, $post_type, $affirmative ) ) {
+ return new \WP_Error( 'afb_update_error', __( 'Sorry, failed to save your request. Please try again later.', 'anyway-feedback' ), [
+ 'status' => 500,
+ ] );
+ }
+ }
+ // This user is posted.
+ $this->user_posted( $object_id, $post_type );
+ do_action( 'afb_user_voted', $post_type, $object_id, $affirmative );
+ // Create request
+ return new \WP_REST_Response( [
+ 'success' => true,
+ 'message' => __( 'Thank you for your feedback.', 'anyway-feedback' ),
+ 'status' => sprintf(
+ // translators: %1$d is number of positive feedbacks, %2$d is total number, %3$s is post type name.
+ __( '%1$d of %2$d people say this %3$s is useful.', 'anyway-feedback' ),
+ afb_affirmative( false, $object_id, $post_type ),
+ afb_total( false, $object_id, $post_type ),
+ $post_type_name
+ ),
+ ] );
+ }
+}
diff --git a/app/Helper/Input.php b/app/Helper/Input.php
index 18f1b75..a6e24d6 100644
--- a/app/Helper/Input.php
+++ b/app/Helper/Input.php
@@ -11,8 +11,8 @@
*
* @package AFB\Helper
*/
-class Input extends Singleton
-{
+class Input extends Singleton {
+
/**
* Constructor
*
@@ -29,8 +29,8 @@ protected function __construct( array $arguments = array() ) {
*
* @return mixed
*/
- public function get($key){
- return isset($_GET[$key]) ? $_GET[$key] : null;
+ public function get( $key ) {
+ return isset( $_GET[ $key ] ) ? $_GET[ $key ] : null;
}
/**
@@ -40,8 +40,8 @@ public function get($key){
*
* @return mixed
*/
- public function post($key){
- return isset($_POST[$key]) ? $_POST[$key] : null;
+ public function post( $key ) {
+ return isset( $_POST[ $key ] ) ? $_POST[ $key ] : null;
}
/**
@@ -51,8 +51,8 @@ public function post($key){
*
* @return mixed
*/
- public function request($key){
- return isset($_REQUEST[$key]) ? $_REQUEST[$key] : null;
+ public function request( $key ) {
+ return isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : null;
}
/**
@@ -63,8 +63,8 @@ public function request($key){
*
* @return bool
*/
- public function check_nonce($action, $key = '_wpnonce'){
- return wp_verify_nonce($this->request($key), $action);
+ public function check_nonce( $action, $key = '_wpnonce' ) {
+ return wp_verify_nonce( $this->request( $key ), $action );
}
-}
\ No newline at end of file
+}
diff --git a/app/Helper/i18n.php b/app/Helper/i18n.php
deleted file mode 100644
index 5661739..0000000
--- a/app/Helper/i18n.php
+++ /dev/null
@@ -1,51 +0,0 @@
-option['post_types']) ){
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
+ // Register script.
+ add_action( 'init', [ $this, 'register_script' ], 9999 );
+ if ( ! empty( $this->option['post_types'] ) ) {
// Add script
- add_action("wp_enqueue_scripts", array($this, "wp_enqueue_scripts"));
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
//...to post
- add_filter('the_content', array($this, 'the_content'));
- if( $this->option['comment'] ){
+ add_filter( 'the_content', array( $this, 'the_content' ) );
+ if ( $this->option['comment'] ) {
//...to comment
- add_filter("comment_text", array($this, "comment_text"), 10, 2);
+ add_filter( 'comment_text', array( $this, 'comment_text' ), 10, 2 );
}
}
// Delete post hook
- add_action('after_delete_post', array($this, 'after_delete_post'));
+ add_action( 'after_delete_post', array( $this, 'after_delete_post' ) );
// Delete comment hook
- add_action('deleted_comment', array($this, 'deleted_comment'));
+ add_action( 'deleted_comment', array( $this, 'deleted_comment' ) );
}
/**
* Enqueue script
*/
- public function wp_enqueue_scripts(){
- if( !wp_script_is('jquery-cookie', 'registered') ){
- wp_register_script('jquery-cookie', $this->assets_url('vendor/jquery.cookie/src/jquery.cookie.js'), array('jquery'), '1.4.1', true);
+ public function wp_enqueue_scripts() {
+ if ( $this->option['style'] ) {
+ wp_enqueue_style( 'anyway-feedback', $this->url . 'dist/css/afb-style.css', [], $this->version, 'screen' );
}
- wp_enqueue_script('anyway-feedback', $this->assets_url('js/anyway-feedback-handler.js', true), array('jquery-cookie'), $this->version, true);
- if( $this->option['style'] ){
- wp_enqueue_style('anyway-feedback', $this->assets_url('css/afb-style.css'), array(), $this->version, 'screen');
+ }
+
+ /**
+ * Register scripts.
+ *
+ * @return void
+ */
+ public function register_script() {
+ if ( ! wp_script_is( 'js-cookie', 'registered' ) ) {
+ wp_register_script( 'js-cookie', $this->assets_url( 'js/js.cookie.min.js', true ), array(), '3.0.2', false );
}
+ wp_register_script( 'anyway-feedback', $this->assets_url( 'js/anyway-feedback-handler.js', true ), [ 'jquery', 'js-cookie', 'wp-api-fetch' ], $this->version, true );
wp_localize_script('anyway-feedback', 'AFBP', array(
- 'ga' => (int)$this->option['ga'],
- 'already' => $this->i18n->_('You have already voted.')
+ 'ga' => (int) $this->option['ga'],
+ 'already' => __( 'You have already voted.', 'anyway-feedback' ),
));
}
+ /**
+ * Default markup.
+ *
+ * @param string $message
+ * @param string $link
+ * @param string $useful
+ * @param string $useless
+ * @param string $status
+ *
+ * @return string
+ */
+ public function default_controller_html( $message, $link, $useful, $useless, $status ) {
+ return <<{$message}
+{$useful}
+{$useless}
+{$status}
+HTML;
+ }
/**
* Make controller
- *
+ *
* @param int $object_id
* @param string $post_type
* @return string
*/
- public function get_controller_tag($object_id, $post_type){
- $post_type_name = ($post_type == "comment") ? $this->i18n->_("Comment") : get_post_type_object($post_type)->labels->singular_name;
- $message = sprintf($this->i18n->_("Is this %s useful?"), $post_type_name);
- $status = sprintf($this->i18n->_('%1$d of %2$d people say this %3$s is useful.'), afb_affirmative(false, $object_id, $post_type), afb_total(false, $object_id, $post_type), $post_type_name);
- $useful = $this->i18n->_("Useful");
- $useless = $this->i18n->_("Useless");
- $url = admin_url('admin-ajax.php');
- $already_posted = $this->does_current_user_posted($post_type, $object_id) ? ' afb_posted' : '';
- $before = <<labels->singular_name;
+ // translators: %s is post type name.
+ $message = sprintf( __( 'Is this %s useful?', 'anyway-feedback' ), $post_type_name );
+ // translators: %1$d is number of positive feedback, %2$d is number of total feedback.
+ $status = sprintf( __( '%1$d of %2$d people say this %3$s is useful.', 'anyway-feedback' ), afb_affirmative( false, $object_id, $post_type ), afb_total( false, $object_id, $post_type ), $post_type_name );
+ $useful = __( 'Useful', 'anyway-feedback' );
+ $useless = __( 'Useless', 'anyway-feedback' );
+ $url = "#afb-{$post_type}-{$object_id}";
+ $id = esc_attr( "afb-container-{$post_type}-{$object_id}" );
+ $before = <<
-
diff --git a/templates/footer.php b/templates/footer.php
index 837c88d..40eb96e 100644
--- a/templates/footer.php
+++ b/templates/footer.php
@@ -1,48 +1,63 @@
-
i18n->e("About Anyway Feedback"); ?>
+
- i18n->e("This plugin enables user to feed back to post or comment. It may help you to analyze your subscriber's feeling.");?>
+
-
i18n->e("Who made this plugin"); ?>
+
-
- i18n->e('Takahashi Fumiki did. I am a WordPress developer and novelist. See detail at WordPrss.org '); ?>
+
+ WordPrss.org'
+ );
+ ?>
-
i18n->e("Contact"); ?>
+
- i18n->e("If you have some request, please feel free to contact via:"); ?>
+
- 'https://wordpress.org/support/plugin/anyway-feedback',
- 'twitter' => 'https://twitter.com/takahashifumiki',
- 'facebook' => 'https://www.facebook.com/TakahashiFumiki.Page',
- 'googleplus' => 'https://plus.google.com/108058172987021898722/about/p/pub',
- ) as $icon => $url ): ?>
-
+ 'twitter' => 'https://twitter.com/takahashifumiki',
+ 'facebook' => 'https://www.facebook.com/TakahashiFumiki.Page',
+ ) as $icon => $url ) :
+ ?>
+
-
i18n->e('Japanese, English and French are welcomed. Of course, you can send pull request via github.com .') ?>
+
+ GitHub'
+ );
+ ?>
+
-
i18n->e("Donation"); ?>
+
- i18n->e("If you think this plugin is usefull, please donate for it and make me motivated. In other words, buy me a beer.");?>
+
-
\ No newline at end of file
+
diff --git a/templates/page/advanced.php b/templates/page/advanced.php
index 57be829..79a9eef 100644
--- a/templates/page/advanced.php
+++ b/templates/page/advanced.php
@@ -1,71 +1,86 @@
-
i18n->e("Template Tags");?>
+
- i18n->e("If you are experienced developper, you may need customazation. Ofcourse, you can edit your theme and get your own appearance."); ?>
+
afb_display ()
- i18n->e("Display controller of post feedback. Use inside loop.");?>
+
afb_comment_display ( (int) $comment_id )
- i18n->e("Display controller of comment feedback. You must pass comment_ID as 1st argument.");?>
+
afb_affirmative ( (boolean) $echo = true , (int) $object_id = null , (string) $post_type = null )
- i18n->e("Display number of affirmative feedbacks of specified post. In loop, you don't have to specify \$object_id and \$post_type. \$echo set true, value won't displayed and just return."); ?>
+
afb_negative ( (boolean) $echo = true , (int) $object_id = null , (string) $post_type = null )
- i18n->e("Display number of negative feedbacks of specified post. Same as afb_affirmative."); ?>
+
afb_total ( (boolean) $echo = true , (int) $object_id = null , (string) $post_type = null )
- i18n->e("Display number of total feedbacks of specified post. Same as afb_affirmative."); ?>
+
- i18n->e("All these template tags above should be wrapped inside if declaration for compatibility. If not, stopping this plugin will break your theme's display."); ?>
+
-
HTML;
-echo esc_html($tag);
+echo esc_html( $tag );
?>
- i18n->_('See function detail at %s
'), dirname(plugin_dir_path(__FILE__)).DIRECTORY_SEPARATOR."functions.php"); ?>
+ %s', 'anyway-feedback' ),
+ dirname( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'functions.php'
+ );
+ ?>
-
i18n->e('Google Analytics') ?>
+
-
i18n->_('You can save all data as event tracking and analize report chronologically. Data format is like below:'), 'https://developers.google.com/analytics/devguides/collection/analyticsjs/events') ?>
+
+ event tracking and analize report chronologically. Data format is like below:', 'anyway-feedback' ),
+ 'https://developers.google.com/analytics/devguides/collection/analyticsjs/events'
+ ) );
+ ?>
+
- i18n->e('Name'); ?>
- i18n->e('Value'); ?>
+
+
@@ -79,17 +94,22 @@
Label
- i18n->e('Post ID
or comment ID
') ?>
+ Post ID or comment ID
', 'anyway-feedback' ) ); ?>
Value
- i18n->e('Always 1') ?>
+
- i18n->_('This feature is premised on Universal Analytics . If you use other services or ga.js, grab the event and record it by yourself.'), 'https://developers.google.com/analytics/devguides/collection/analyticsjs/'); ?>
+ Google Analytics 4. If you use other services or Google Tag Manager, grab the event and record it by yourself.', 'anyway-feedback' ),
+ 'https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag&sjid=8607412637313615612-AP' );
+ ?>
@@ -112,8 +132,8 @@
});
})(jQuery);
JS;
-echo esc_html($script);
+echo esc_html( $script );
?>
-
\ No newline at end of file
+
diff --git a/templates/page/setting.php b/templates/page/setting.php
index 0a4dc8b..49cfb92 100644
--- a/templates/page/setting.php
+++ b/templates/page/setting.php
@@ -1,97 +1,55 @@
-
+ __( 'Checked post type will be active for feedbacks and display controller inside post content via the_content
hook.', 'anyway-feedback' ),
+ 'comment' => __( 'This option decide to display feedback controller in comment loop. This affects all comment of commentable post types.', 'anyway-feedback' ),
+ 'style' => __( 'If you select "No style", you need a custom style sheet for the controller UI. Mark up can be specified at Custom markup section', 'anyway-feedback' ),
+ 'hide_default_controller' => __( 'Checked post types are still active for feedbacks, but you need custom code to display the controller. See "Advanced Usage" section.', 'anyway-feedback' ),
+ 'controller' => implode( ' ', [
+ __( 'You can customize markup of Feedback controller. If you don\'t want, leave it blank.', 'anyway-feedback' ),
+ __( 'In case of customization, You can use variables(%POSITIVE%
, %TOTAL%
, %NEGATIVE%
, %POST_TYPE%
) and 2 link tags <a>
must have class name good
and bad
and %LINK%
as href attribute.', 'anyway-feedback' ),
+ __( 'Default markup is below:', 'anyway-feedback' ),
+ ] ),
+ 'ga' => sprintf(
+ // translators: %s is a url.
+ __( 'This feature send report as event tracking to Google Analytics. You can get chronological report there. For detail, see Advanced Usage . ', 'anyway-feedback' ),
+ // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewClosure.ThisFoundOutsideClass
+ $this->setting_url( 'advanced' )
+ ),
+ ];
+
+ if ( ! empty( $messages[ $key ] ) ) {
+ printf(
+ '%s
',
+ wp_kses_post( $messages[ $key ] )
+ );
+ }
+ if ( 'controller' === $key ) {
+ ?>
+
+ default_controller_html( $message, '%LINK%', $useful, $useless, $status );
+ echo esc_html( $markup )
+ ?>
+
+
diff --git a/templates/statistic.php b/templates/statistic.php
index 95e4653..372ac4e 100644
--- a/templates/statistic.php
+++ b/templates/statistic.php
@@ -1,33 +1,40 @@
-
i18n->_('Feedback Statistic of %s'), $post_type->labels->name) ?>
+
+
+ labels->name );
+ ?>
+
-
+
- prepare_items() ?>
+ prepare_items(); ?>
-
-
-
- search_box($this->i18n->_('Search'), 's'); ?>
+
+
+
+ search_box( __( 'Search', 'anyway-feedback' ), 's' ); ?>
display(); ?>
- load_template('footer.php') ?>
+ load_template( 'footer.php' ); ?>
-
\ No newline at end of file
+
diff --git a/uninstall.php b/uninstall.php
index 4b61a3f..9f31258 100644
--- a/uninstall.php
+++ b/uninstall.php
@@ -1,23 +1,29 @@
prefix}afb_feedbacks
SQL;
-$wpdb->query($query);
+// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
+$wpdb->query( $query );