Skip to content

Commit

Permalink
Merge pull request #8 from LinkNacional/dev
Browse files Browse the repository at this point in the history
2.0.1 Alteração em plugin para manter as normativas do wordpress
  • Loading branch information
emanuellopess authored Jul 17, 2024
2 parents 352b510 + 7bfac42 commit 46679e1
Show file tree
Hide file tree
Showing 22 changed files with 784 additions and 874 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Make plugin root directory
run: |
mkdir ${{env.PLUGIN_NAME}} &&
cp -r ./admin ./includes ./languages ./public *.php *.txt composer.json composer.lock ./${{env.PLUGIN_NAME}}/ &&
cp -r ./Admin ./Includes ./languages ./Public *.php *.txt composer.json composer.lock ./${{env.PLUGIN_NAME}}/ &&
find ./${{env.PLUGIN_NAME}} -type f -exec chmod 0644 {} + &&
find ./${{env.PLUGIN_NAME}} -type d -exec chmod 0755 {} + &&
ls -lah
Expand All @@ -50,7 +50,7 @@ jobs:
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: "1.0.0" # This tag will be updated by the action // TODO Update this value
custom_tag: "2.0.1" # This tag will be updated by the action // TODO Update this value

# Generate new release
- name: Generate new Release
Expand Down
3 changes: 1 addition & 2 deletions .vscode/.php-cs-fixer-wp.php → .vscode/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,4 @@
))
->setIndent(' ')
->setLineEnding("\n")
->setRiskyAllowed(true)
;
->setRiskyAllowed(true);
35 changes: 14 additions & 21 deletions Admin/PGPFGForGivewpAdmin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Lkn\PGPFGForGivewp\Admin;
namespace Pgpfg\PGPFGForGivewp\Admin;

use Lkn\PGPFGForGivewp\Includes\PGPFGHelperClass;
use Pgpfg\PGPFGForGivewp\Includes\PGPFGHelperClass;
use WP_Error;

/**
Expand All @@ -25,8 +25,7 @@
* @subpackage PGPFGForGivewp/admin
* @author Link Nacional <[email protected]>
*/
final class PGPFGForGivewpAdmin
{
final class PGPFGForGivewpAdmin {
/**
* The ID of this plugin.
*
Expand All @@ -52,8 +51,7 @@ final class PGPFGForGivewpAdmin
* @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 . '-admin';
$this->version = $version;
}
Expand All @@ -65,21 +63,20 @@ public function __construct($plugin_name, $version)
*
* @return array
*/
public function add_setting_into_new_section($settings)
{
public function add_setting_into_new_section($settings) {
switch (give_get_current_setting_section()) {
case 'lkn-payment-pix':
// Verifique se a configuração específica já está no array
$exists = false;
foreach ($settings as $setting) {
if (isset($setting['id']) && $setting['id'] === 'lkn-payment-pix-type-setting') {
if (isset($setting['id']) && 'lkn-payment-pix-type-setting' === $setting['id']) {
$exists = true;
break;
}
}

// Adicione as configurações apenas se ainda não existirem
if (!$exists) {
if ( ! $exists) {
$settings[] = array(
'type' => 'title',
'id' => 'lkn-payment-pix'
Expand Down Expand Up @@ -170,8 +167,7 @@ public function add_setting_into_new_section($settings)
*
* @return array
*/
public function add_new_setting_section($sections)
{
public function add_new_setting_section($sections) {
// Separar palavras com travessão no atributo $sections
$sections['lkn-payment-pix'] = __('Pix QR Code', 'payment-gateway-pix-for-givewp');

Expand All @@ -183,8 +179,7 @@ public function add_new_setting_section($sections)
*
* @since 1.0.0
*/
public function enqueue_styles(): void
{
public function enqueue_styles(): void {
/**
* This function is provided for demonstration purposes only.
*
Expand All @@ -204,8 +199,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 All @@ -223,10 +217,10 @@ public function enqueue_scripts(): void
$logPath = give_get_option('pgpfg_for_givewp_last_log_url');
$wp_error = false;
$remote = null;
if ($logPath !== false) {
if (false !== $logPath) {
$remote = wp_remote_get($logPath);

if(gettype($remote) === gettype(new WP_Error())) {
if (gettype($remote) === gettype(new WP_Error())) {
PGPFGHelperClass::log(wp_json_encode(array(
'Remote Response' => $remote,
'log url' => $logPath,
Expand All @@ -235,18 +229,17 @@ public function enqueue_scripts(): void

$wp_error = $remote;
}

}
$logContents = wp_remote_retrieve_body($remote);

wp_localize_script(
$this->plugin_name,
'lknAttr',
[
array(
'logContents' => ($wp_error ? wp_json_encode(array(
'Error' => 'Error retrieving log'
), JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : $logContents)
]
)
);
}
}
84 changes: 41 additions & 43 deletions Admin/js/pgpfg-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,47 +52,43 @@ const { __ } = wp.i18n;
noticeDiv.innerHTML += '<a style="margin: 18px; padding-right: 0px; margin-top: 20px;" href="https://www.linknacional.com.br/wordpress/givewp/" target="_blank">' + __('Learn more now', 'payment-gateway-pix-for-givewp') + '</a>'

const lknCieloNoticeDiv = document.createElement('div')
lknCieloNoticeDiv.setAttribute('style', "background-color: #fcf9e8;color: #646970;border: solid 1px #d3d3d3;border-left: 4px #dba617 solid;font-size: 16px;margin-top: 10px;")
lknCieloNoticeDiv.setAttribute('style', 'background-color: #fcf9e8;color: #646970;border: solid 1px #d3d3d3;border-left: 4px #dba617 solid;font-size: 16px;margin-top: 10px;')
lknCieloNoticeDiv.setAttribute('id', 'lkn-cielo-hosting-notice')

lknCieloNoticeDiv.innerHTML = '<a href="https://www.linknacional.com.br/wordpress/" target="_blank" style="text-decoration:none; display: block;padding: 10px;">' + __('WordPress Maintenance and Support!', 'payment-gateway-pix-for-givewp') + '</a>'



if (giveForm && lknCieloNoticeDiv) {
giveForm.after(noticeDiv)
noticeDiv.after(lknCieloNoticeDiv)

const linkInNoticeDiv = noticeDiv.getElementsByTagName('a');
const linkLknCieloInNoticeDiv = lknCieloNoticeDiv.getElementsByTagName('a');
const linkInNoticeDiv = noticeDiv.getElementsByTagName('a')
const linkLknCieloInNoticeDiv = lknCieloNoticeDiv.getElementsByTagName('a')

setDarkCss(linkInNoticeDiv, linkLknCieloInNoticeDiv, noticeDiv, lknCieloNoticeDiv)

WPDarkMode.onChange(() => {

if (WPDarkMode.isActive) {
setDarkCss(linkInNoticeDiv, linkLknCieloInNoticeDiv, noticeDiv, lknCieloNoticeDiv)

} else {
const linkInNoticeDiv = noticeDiv.getElementsByTagName('a');
const linkLknCieloInNoticeDiv = lknCieloNoticeDiv.getElementsByTagName('a');

if (linkInNoticeDiv && linkLknCieloInNoticeDiv) {
for (let i = 0; i < linkInNoticeDiv.length; i++) {
linkInNoticeDiv[i].style.color = '#2271b1';
if (typeof WPDarkMode !== 'undefined') {
WPDarkMode.onChange(() => {
if (WPDarkMode.isActive) {
setDarkCss(linkInNoticeDiv, linkLknCieloInNoticeDiv, noticeDiv, lknCieloNoticeDiv)
} else {
const linkInNoticeDiv = noticeDiv.getElementsByTagName('a')
const linkLknCieloInNoticeDiv = lknCieloNoticeDiv.getElementsByTagName('a')

if (linkInNoticeDiv && linkLknCieloInNoticeDiv) {
for (let i = 0; i < linkInNoticeDiv.length; i++) {
linkInNoticeDiv[i].style.color = '#2271b1'
}
for (let i = 0; i < linkLknCieloInNoticeDiv.length; i++) {
linkLknCieloInNoticeDiv[i].style.color = '#2271b1'
}
}
for (let i = 0; i < linkLknCieloInNoticeDiv.length; i++) {
linkLknCieloInNoticeDiv[i].style.color = '#2271b1';
}
}

noticeDiv.style.color = '#646970'
noticeDiv.style.backgroundColor = '#fcf9e8'
lknCieloNoticeDiv.style.color = '#646970'
lknCieloNoticeDiv.style.backgroundColor = '#fcf9e8'
}
});

noticeDiv.style.color = '#646970'
noticeDiv.style.backgroundColor = '#fcf9e8'
lknCieloNoticeDiv.style.color = '#646970'
lknCieloNoticeDiv.style.backgroundColor = '#fcf9e8'
}
})
}
}
const checkLogs = $('#check-logs')

Expand All @@ -106,25 +102,27 @@ const { __ } = wp.i18n;
}
}

function setDarkCss(linkInNoticeDiv, linkLknCieloInNoticeDiv, noticeDiv, lknCieloNoticeDiv) {
if (WPDarkMode.isActive) {
noticeDiv.style.color = 'white'
noticeDiv.style.backgroundColor = '#292a2a'
lknCieloNoticeDiv.style.backgroundColor = '#292a2a'
lknCieloNoticeDiv.style.color = 'white'

if (linkInNoticeDiv && linkLknCieloInNoticeDiv) {
for (let i = 0; i < linkInNoticeDiv.length; i++) {
linkInNoticeDiv[i].style.color = 'lightblue';
}
for (let i = 0; i < linkLknCieloInNoticeDiv.length; i++) {
linkLknCieloInNoticeDiv[i].style.color = 'lightblue';
function setDarkCss (linkInNoticeDiv, linkLknCieloInNoticeDiv, noticeDiv, lknCieloNoticeDiv) {
if (typeof WPDarkMode !== 'undefined') {
if (WPDarkMode.isActive) {
noticeDiv.style.color = 'white'
noticeDiv.style.backgroundColor = '#292a2a'
lknCieloNoticeDiv.style.backgroundColor = '#292a2a'
lknCieloNoticeDiv.style.color = 'white'

if (linkInNoticeDiv && linkLknCieloInNoticeDiv) {
for (let i = 0; i < linkInNoticeDiv.length; i++) {
linkInNoticeDiv[i].style.color = 'lightblue'
}
for (let i = 0; i < linkLknCieloInNoticeDiv.length; i++) {
linkLknCieloInNoticeDiv[i].style.color = 'lightblue'
}
}
}
}
}

function lknFindGetParameter(parameterName) {
function lknFindGetParameter (parameterName) {
let result = null
let tmp = []
location.search
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.0.1 - 16/07/2024
* Alteração em plugin para manter as normativas do wordpress.

# 2.0.0 - 24/06/2024
* Migração para programação orientada a objetos;
* Implementação de autoloader;
Expand Down
Loading

0 comments on commit 46679e1

Please sign in to comment.