Skip to content

Commit

Permalink
refactor: Update style to standard defined in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuellopess committed Aug 7, 2024
1 parent 6aa7028 commit 6d7ba38
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 151 deletions.
20 changes: 7 additions & 13 deletions admin/class-lkn-antispam-for-givewp-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*
* @author Link Nacional
*/
final class Lkn_Antispam_For_GiveWP_Admin
{
final class Lkn_Antispam_For_GiveWP_Admin {
/**
* The ID of this plugin.
*
Expand All @@ -43,8 +42,7 @@ final class Lkn_Antispam_For_GiveWP_Admin
* @param string $plugin_name the name of this plugin
* @param string $version the version of this plugin
*/
public function __construct($plugin_name, $version)
{
public function __construct($plugin_name, $version) {
$this->plugin_name = $plugin_name;
$this->version = $version;

Expand All @@ -60,8 +58,7 @@ public function __construct($plugin_name, $version)
*
* @return array
*/
public function lkn_antispam_for_givewp_add_setting_into_existing_tab($settings)
{
public function lkn_antispam_for_givewp_add_setting_into_existing_tab($settings) {
if ( ! Give_Admin_Settings::is_setting_page('general', 'access-control')) {
return $settings;
}
Expand Down Expand Up @@ -129,7 +126,7 @@ public function lkn_antispam_for_givewp_add_setting_into_existing_tab($settings)
'type' => 'number',
'default' => '2',
);

$newSetting[] = array(
'name' => __('Interval between donations', 'antispam-donation-for-givewp'),
'id' => 'lkn_antispam_time_interval_setting_field',
Expand Down Expand Up @@ -253,8 +250,7 @@ public function lkn_antispam_for_givewp_add_setting_into_existing_tab($settings)
}

// Insert settings on GiveWP settings
public function include_settings(): void
{
public function include_settings(): void {
add_filter('give_get_settings_general', array($this, 'lkn_antispam_for_givewp_add_setting_into_existing_tab'), 10, 1);
}

Expand All @@ -263,8 +259,7 @@ public function include_settings(): void
*
* @since 1.0.0
*/
public function enqueue_styles(): void
{
public function enqueue_styles(): void {
/*
* This function is provided for demonstration purposes only.
*
Expand All @@ -285,8 +280,7 @@ public function enqueue_styles(): void
*
* @since 1.0.0
*/
public function enqueue_scripts(): void
{
public function enqueue_scripts(): void {
/*
* This function is provided for demonstration purposes only.
*
Expand Down
1 change: 0 additions & 1 deletion admin/js/lkn-antispam-for-givewp-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@
})
}
})

// eslint-disable-next-line no-undef
})(jQuery)
4 changes: 1 addition & 3 deletions admin/js/lkn-antispam-for-givewp-link.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
document.addEventListener('DOMContentLoaded', function () {
const linkA = document.getElementById('lkn-antispam-link')
if(linkA){
if (linkA) {
const links = link.href + '?unlock=true'
linkA.href = links

}

})
12 changes: 5 additions & 7 deletions admin/js/lkn-antispam-for-givewp-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ window.addEventListener('load', function () {

if (page === 'give-settings' && tab === 'general' && section === 'access-control') {
// Setting max length option for pagseguro description field.
const wcForm = document.querySelector('.give-docs-link');
const wcForm = document.querySelector('.give-docs-link')

if (wcForm) {
const noticeDiv = document.createElement('div');
const noticeDiv = document.createElement('div')

noticeDiv.innerHTML = `
<div style='background-color: #fcf9e8;color: #646970;border: solid 1px #d3d3d3;border-left: 4px #dba617 solid;font-size: 16px;margin-top: 10px;'>
<a target="_blank" style="text-decoration:none; display: block;padding: 10px;">AntiSpam não esta compatível com formulários 3.0 do GiveWP.</a>
</div>
`;
wcForm.insertAdjacentElement('beforebegin', noticeDiv);
`
wcForm.insertAdjacentElement('beforebegin', noticeDiv)
} else {
console.error('O formulário de configurações do gateway não foi encontrado.');
console.error('O formulário de configurações do gateway não foi encontrado.')
}
}


})
6 changes: 3 additions & 3 deletions includes/class-lkn-antispam-for-givewp-deactivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*
* @author Link Nacional
*/
final class Lkn_Antispam_For_GiveWP_Deactivator
{
final class Lkn_Antispam_For_GiveWP_Deactivator {
/**
* Short Description. (use period).
*
* Long Description.
*
* @since 1.0.0
*/
public static function deactivate(): void {}
public static function deactivate(): void {
}
}
39 changes: 13 additions & 26 deletions includes/class-lkn-antispam-for-givewp-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
exit;
}

abstract class Lkn_Antispam_Helper
{
abstract class Lkn_Antispam_Helper {
/**
* Show plugin dependency notice.
*
* @since
*/
final public static function verify_plugin_dependencies(): void
{
final public static function verify_plugin_dependencies(): void {
// Load plugin helper functions.
if ( ! function_exists('deactivate_plugins') || ! function_exists('is_plugin_active')) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
Expand Down Expand Up @@ -64,8 +62,7 @@ final public static function verify_plugin_dependencies(): void
}
}

final public static function dependency_notice(): void
{
final public static function dependency_notice(): void {
// Admin notice.
$message = sprintf(
'<div class="notice notice-error"><p><strong>%1$s</strong> %2$s <a href="%3$s" target="_blank">%4$s</a> %5$s %6$s+ %7$s.</p></div>',
Expand All @@ -86,8 +83,7 @@ final public static function dependency_notice(): void
*
* @since
*/
final public static function inactive_notice(): void
{
final public static function inactive_notice(): void {
// Admin notice.
$message = sprintf(
'<div class="notice notice-error"><p><strong>%1$s</strong> %2$s <a href="%3$s" target="_blank">%4$s</a> %5$s.</p></div>',
Expand All @@ -110,8 +106,7 @@ final public static function inactive_notice(): void
*
* @return array
*/
final public static function plugin_row_meta($plugin_meta)
{
final public static function plugin_row_meta($plugin_meta) {
$new_meta_links['setting'] = sprintf(
'<a href="%1$s">%2$s</a>',
admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general&section=access-control'),
Expand All @@ -126,8 +121,7 @@ final public static function plugin_row_meta($plugin_meta)
*
* @return array
*/
final public static function get_configs()
{
final public static function get_configs() {
$configs = array();

$configs['basePath'] = LKN_ANTISPAM_FOR_GIVEWP_DIR;
Expand Down Expand Up @@ -157,8 +151,7 @@ final public static function get_configs()
/**
* Delete the log files older than 5 days.
*/
final public static function delete_old_logs(): void
{
final public static function delete_old_logs(): void {
$configs = Lkn_Antispam_Helper::get_configs();
$logsPath = $configs['basePath'] . 'logs/';

Expand Down Expand Up @@ -186,18 +179,15 @@ final public static function delete_old_logs(): void
}
}

final public static function dependency_alert(): void
{
final public static function dependency_alert(): void {
add_action('admin_notices', array('Lkn_Antispam_Helper', 'dependency_notice'));
}

final public static function inactive_alert(): void
{
final public static function inactive_alert(): void {
add_action('admin_notices', array('Lkn_Antispam_Helper', 'inactive_notice'));
}

final public static function block_all_payments($gateway_list)
{
final public static function block_all_payments($gateway_list) {
$option = give_get_option('lkn_antispam_spam_detected_block_all');
if (true == $option) {
return array();
Expand All @@ -206,13 +196,11 @@ final public static function block_all_payments($gateway_list)
return $gateway_list;
}

final public static function remove_status_block_all_payments(): void
{
final public static function remove_status_block_all_payments(): void {
give_update_option('lkn_antispam_spam_detected_block_all', false);
}

final public static function create_custom_page(): int
{
final public static function create_custom_page(): int {
// Título do template
$template_title = 'Meu Template';

Expand Down Expand Up @@ -249,8 +237,7 @@ final public static function create_custom_page(): int
return $template_id;
}

final public static function add_php_custom_page($content)
{
final public static function add_php_custom_page($content) {
// Verifica se é a página desejada (substitua 'page-slug' pelo slug da página)
if (is_page('Meu Template')) {
// Adiciona o código PHP ao conteúdo da página
Expand Down
6 changes: 2 additions & 4 deletions includes/class-lkn-antispam-for-givewp-i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
*
* @author Link Nacional
*/
final class Lkn_Antispam_For_GiveWP_i18n
{
final class Lkn_Antispam_For_GiveWP_i18n {
/**
* Load the plugin text domain for translation.
*
* @since 1.0.0
*/
public function load_plugin_textdomain(): void
{
public function load_plugin_textdomain(): void {
load_plugin_textdomain(
'antispam-donation-for-givewp',
false,
Expand Down
18 changes: 6 additions & 12 deletions includes/class-lkn-antispam-for-givewp-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*
* @author Link Nacional
*/
final class Lkn_Antispam_For_GiveWP_Loader
{
final class Lkn_Antispam_For_GiveWP_Loader {
/**
* The array of actions registered with WordPress.
*
Expand All @@ -41,8 +40,7 @@ final class Lkn_Antispam_For_GiveWP_Loader
*
* @since 1.0.0
*/
public function __construct()
{
public function __construct() {
$this->actions = array();
$this->filters = array();
}
Expand All @@ -58,8 +56,7 @@ public function __construct()
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
*/
public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1): void
{
public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1): void {
$this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
}

Expand All @@ -74,8 +71,7 @@ public function add_action($hook, $component, $callback, $priority = 10, $accept
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
*/
public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1): void
{
public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1): void {
$this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
}

Expand All @@ -84,8 +80,7 @@ public function add_filter($hook, $component, $callback, $priority = 10, $accept
*
* @since 1.0.0
*/
public function run(): void
{
public function run(): void {
foreach ($this->filters as $hook) {
add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
}
Expand All @@ -110,8 +105,7 @@ public function run(): void
*
* @return array the collection of actions and filters registered with WordPress
*/
private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
{
private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) {
$hooks[] = array(
'hook' => $hook,
'component' => $component,
Expand Down
Loading

0 comments on commit 6d7ba38

Please sign in to comment.