Skip to content

Commit

Permalink
v 0.17.1
Browse files Browse the repository at this point in the history
- Update dependencies
- Handle more fields in result template.
  • Loading branch information
Darklg committed Apr 25, 2024
1 parent ab112ae commit d8f379c
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install modules
run: npm install -g eslint
run: npm install -g eslint@^8
- name: Run ESLint
run: eslint assets/ --ext .js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mo.php
7 changes: 3 additions & 4 deletions assets/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ document.addEventListener('DOMContentLoaded', function() {
var $message = $main.find('.wpu-poll-main__message');
$main.attr('data-prevent-form', '1');
$message.html(response.data.error_message);
}
else {
} else {
$button.prop('disabled', false);
$main.find('input:checked').prop('checked', false);
}
Expand Down Expand Up @@ -182,8 +181,8 @@ document.addEventListener('DOMContentLoaded', function() {
_count_str = wpu_polls_settings.str_n_votes.replace('%d', _nb_results);
}
$item.attr('data-count', _nb_results);
$item.find('.percent').text(_percent + '%');
$item.find('.count').text(_count_str);
$item.find('.percent,[data-wpupolls-value="percent"]').text(_percent + '%');
$item.find('.count,[data-wpupolls-value="count"]').text(_count_str);
$item.find('.bar-count').css('width', _percent + '%');
}

Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseAdminDatas/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
34 changes: 21 additions & 13 deletions inc/WPUBaseAdminDatas/WPUBaseAdminDatas.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
Class Name: WPU Base Admin Datas
Description: A class to handle datas in WordPress admin
Version: 3.10.1
Version: 3.12.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
Expand Down Expand Up @@ -419,7 +419,7 @@ public function delete_lines($lines = array()) {
public function export_array_to_csv($array, $name) {
if (isset($array[0])) {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=export-list-' . $name . '-' . date_i18n('y-m-d') . '.csv');
header('Content-Disposition: attachment; filename=export-list-' . sanitize_title($name) . '-' . date_i18n('y-m-d') . '.csv');
header('Pragma: no-cache');
echo implode(';', array_keys($array[0])) . "\n";
foreach ($array as $line) {
Expand Down Expand Up @@ -554,9 +554,9 @@ public function get_admin_item($item_id = false) {
if ($item_id) {
$_html .= '<h3>#' . $item_id . '</h3>';
} else {
$_html .= '<h3>' . __('New Post') . '</h3>';
$_html .= '<h3>' . __('New Post', $this->settings['plugin_id']) . '</h3>';
}
$_html .= '<a href="' . add_query_arg($_back_url_args, $this->pagename) . '">' . __('Back') . '</a>';
$_html .= '<a href="' . add_query_arg($_back_url_args, $this->pagename) . '">' . __('Back', $this->settings['plugin_id']) . '</a>';

$_html .= '<table class="form-table"><tbody>';
foreach ($this->settings['table_fields'] as $id => $field) {
Expand Down Expand Up @@ -615,6 +615,10 @@ public function get_admin_table($values = array(), $args = array()) {
$args['perpage'] = $this->default_perpage;
}

if (!isset($args['has_export'])) {
$args['has_export'] = true;
}

// Add ID
$default_columns = array(
'creation' => array(
Expand Down Expand Up @@ -782,9 +786,9 @@ public function get_admin_table($values = array(), $args = array()) {
$search_form .= '<input type="hidden" name="order" value="' . esc_attr($args['order']) . '" />';
$search_form .= '<input type="hidden" name="orderby" value="' . esc_attr($args['orderby']) . '" />';
$search_form .= '<input type="search" name="where_text" value="' . esc_attr($where_text) . '" />';
$search_form .= get_submit_button(__('Search'), '', 'submit', false);
$search_form .= get_submit_button(__('Search', $this->settings['plugin_id']), '', 'submit', false);
if ($where_text) {
$search_form .= '<br /><small><a href="' . add_query_arg($url_items_clear, $this->pagename) . '">' . __('Clear') . '</a></small>';
$search_form .= '<br /><small><a href="' . add_query_arg($url_items_clear, $this->pagename) . '">' . __('Clear', $this->settings['plugin_id']) . '</a></small>';
}
$search_form .= '</p><br class="clear" /></form><div class="clear"></div>';

Expand All @@ -796,7 +800,7 @@ public function get_admin_table($values = array(), $args = array()) {
$content .= wp_nonce_field('action-main-form-' . $page_id, 'action-main-form-admin-datas-' . $page_id, true, false);
if ($has_id && $is_admin_view && $this->settings['can_create']) {
$new_url = add_query_arg(array('backquery' => $_back_query), $this->pagename . '&create=1');
$content .= '<p><a class="page-title-action" href="' . $new_url . '">' . __('New Post') . '</a></p>';
$content .= '<p><a class="page-title-action" href="' . $new_url . '">' . __('New Post', $this->settings['plugin_id']) . '</a></p>';
}
$content .= '<table class="wp-list-table widefat striped">';
if (isset($args['columns']) && is_array($args['columns']) && !empty($args['columns'])) {
Expand Down Expand Up @@ -841,29 +845,33 @@ public function get_admin_table($values = array(), $args = array()) {

$content .= $cell_content;
if ($cell_id == $args['primary_column']) {
$content .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details') . '</span></button>';
$content .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details', $this->settings['plugin_id']) . '</span></button>';
}
$content .= '</td>';
}
if ($has_id && $is_admin_view) {
$edit_url = add_query_arg(array('backquery' => $_back_query), $this->pagename . '&item_id=' . $vals->id);
$content .= '<td><a href="' . $edit_url . '">' . ($this->settings['can_edit'] ? __('Edit') : __('View')) . '</a></td>';
$content .= '<td><a href="' . $edit_url . '">' . ($this->settings['can_edit'] ? __('Edit', $this->settings['plugin_id']) : __('View', $this->settings['plugin_id'])) . '</a></td>';
}
$content .= '</tr>';
}
$content .= '</tbody>';
$content .= '</table>';
if ($has_id) {
$content .= '<p class="admindatas-delete-button">' . get_submit_button(__('Delete'), 'delete', 'delete_lines', false) . '</p>';
$content .= '<p class="admindatas-delete-button">' . get_submit_button(__('Delete', $this->settings['plugin_id']), 'delete', 'delete_lines', false) . '</p>';
}
$content .= '</form>';
$content .= $clear_form;
$content .= $search_form;
$content .= $pagination;
$content .= '<a href="' . admin_url($export_url_base) . '">' . __('Export all') . '</a>';
if ($where_text || $has_filter_key) {
$content .= ' <a href="' . admin_url($export_url) . '">' . __('Export filtered view') . '</a>';

if ($args['has_export']) {
$content .= '<a href="' . admin_url($export_url_base) . '">' . __('Export all', $this->settings['plugin_id']) . '</a>';
if ($where_text || $has_filter_key) {
$content .= ' <a href="' . admin_url($export_url) . '">' . __('Export filtered view', $this->settings['plugin_id']) . '</a>';
}
}

$content .= <<<HTML
<style>
.admindatas-search-filter{
Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseAdminDatas/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
5 changes: 5 additions & 0 deletions inc/WPUBaseFields/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
deny from all

<FilesMatch "(^$)|(\.(css|js)$)">
Allow From All
</FilesMatch>
1 change: 1 addition & 0 deletions inc/WPUBaseFields/assets/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseFields/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseMessages/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
1 change: 1 addition & 0 deletions inc/WPUBaseMessages/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
1 change: 1 addition & 0 deletions inc/WPUBaseSettings/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
1 change: 1 addition & 0 deletions inc/WPUBaseSettings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if (is_admin()) {
## Insert in your admin page content ( if needed )

```php
settings_errors();
echo '<form action="' . admin_url('options.php') . '" method="post">';
settings_fields($this->settings_details['option_id']);
do_settings_sections($this->options['plugin_id']);
Expand Down
10 changes: 9 additions & 1 deletion inc/WPUBaseSettings/WPUBaseSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
Class Name: WPU Base Settings
Description: A class to handle native settings in WordPress admin
Version: 0.18.1
Version: 0.19.0
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
Expand Down Expand Up @@ -219,6 +219,9 @@ public function add_settings() {
'id' => $id,
'lang_id' => $lang_id,
'label_for' => $id,
'readonly' => isset($this->settings[$id]['readonly']) ? $this->settings[$id]['readonly'] : false,
'placeholder' => isset($this->settings[$id]['placeholder']) ? $this->settings[$id]['placeholder'] : false,
'attributes_html' => isset($this->settings[$id]['attributes_html']) ? $this->settings[$id]['attributes_html'] : false,
'translated_from' => isset($this->settings[$id]['translated_from']) ? $this->settings[$id]['translated_from'] : false,
'required' => $this->settings[$id]['required'],
'post_type' => $this->settings[$id]['post_type'],
Expand Down Expand Up @@ -311,12 +314,17 @@ public function render__field($args = array()) {
$name = ' name="' . $name_val . '" ';
$id = ' id="' . $args['id'] . '" ';
$attr = '';
if (isset($args['readonly']) && $args['readonly']) {
$attr .= ' readonly ';
$name = '';
}
if (isset($args['lang_id']) && $args['lang_id']) {
$attr .= ' data-wpulang="' . esc_attr($args['lang_id']) . '" ';
}
if (isset($args['required']) && $args['required']) {
$attr .= ' required="required" ';
}

if (isset($args['placeholder']) && $args['placeholder']) {
$attr .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
}
Expand Down
1 change: 1 addition & 0 deletions inc/WPUBaseSettings/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php /* Silence */
7 changes: 4 additions & 3 deletions wpu_polls.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
Plugin URI: https://github.com/WordPressUtilities/wpu_polls
Update URI: https://github.com/WordPressUtilities/wpu_polls
Description: WPU Polls handle simple polls
Version: 0.17.0
Version: 0.17.1
Author: Darklg
Author URI: https://darklg.me/
Text Domain: wpu_polls
Domain Path: /lang
Requires at least: 6.2
Requires PHP: 8.0
Network: Optional
License: MIT License
License URI: https://opensource.org/licenses/MIT
*/
Expand All @@ -23,7 +24,7 @@ class WPUPolls {
public $basefields;
public $settings_details;
public $settings;
private $plugin_version = '0.17.0';
private $plugin_version = '0.17.1';
private $plugin_settings = array(
'id' => 'wpu_polls',
'name' => 'WPU Polls'
Expand Down Expand Up @@ -1037,7 +1038,7 @@ private function get_vote_content($poll_id) {
$html .= '</div>';
} else {
$html .= '<div data-nosnippet class="wpu-poll-results">';
$html .= '<ul data-has-image="' . ($has_answer_image ? '1' : '0') . '">';
$html .= '<ul class="wpu-poll-results__list" data-has-image="' . ($has_answer_image ? '1' : '0') . '">';
$html .= $html_results;
$html .= '</ul>';
$html .= '</div>';
Expand Down

0 comments on commit d8f379c

Please sign in to comment.