Skip to content

Commit

Permalink
v 2.53.1
Browse files Browse the repository at this point in the history
Base Fields v 0.16.1
- Handle display base on two fields.
  • Loading branch information
Darklg committed Aug 3, 2023
1 parent da4ce29 commit 96730a9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 24 deletions.
6 changes: 3 additions & 3 deletions inc/WPUBaseFields/WPUBaseFields.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace wpubasefields_0_16_0;
namespace wpubasefields_0_16_1;

/*
Class Name: WPU Base Fields
Description: A class to handle fields in WordPress
Version: 0.16.0
Version: 0.16.1
Class URI: https://github.com/WordPressUtilities/wpubaseplugin
Author: Darklg
Author URI: https://darklg.me/
Expand All @@ -14,7 +14,7 @@

class WPUBaseFields {
private $script_id;
private $version = '0.16.0';
private $version = '0.16.1';
private $fields = array();
private $field_groups = array();
private $supported_types = array(
Expand Down
38 changes: 20 additions & 18 deletions inc/WPUBaseFields/assets/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,30 @@ document.addEventListener("DOMContentLoaded", function() {
return;
}

for (var _key in _data) {
(function(_key, _value, $wrapper) {
var $input = document.getElementById('wpubasefields_' + _key);

function check_value() {
var _visible = true;
if (_value == 'checked') {
if (!$input.checked) {
_visible = false;
}
function check_values() {
var _visible = true,
$input;
for (var _key in _data) {
$input = document.getElementById('wpubasefields_' + _key);
if (_data[_key] == 'checked') {
if (!$input.checked) {
_visible = false;
}
else {
if (_value != $input.value) {
_visible = false;
}
}
else {
if (_data[_key] != $input.value) {
_visible = false;
}
$wrapper.setAttribute('data-visible', _visible ? '1' : '0');
}
check_value();
$input.addEventListener('change', check_value, 1);
}(_key, _data[_key], $wrapper));
}
$wrapper.setAttribute('data-visible', _visible ? '1' : '0');
}

for (var _key in _data) {
document.getElementById('wpubasefields_' + _key).addEventListener('change', check_values, 1);
}

check_values();
});

/* ----------------------------------------------------------
Expand Down
20 changes: 17 additions & 3 deletions wpubaseplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Plugin URI: https://github.com/WordPressUtilities/wpubaseplugin
Update URI: https://github.com/WordPressUtilities/wpubaseplugin
Description: A framework for a WordPress plugin
Version: 2.53.0
Version: 2.53.1
Author: Darklg
Author URI: https://darklg.me/
Text Domain: wpubaseplugin
Expand All @@ -18,7 +18,7 @@

class WPUBasePlugin {

public $version = '2.53.0';
public $version = '2.53.1';

private $utilities_classes = array(
'messages' => array(
Expand All @@ -42,7 +42,7 @@ class WPUBasePlugin {
'name' => 'WPUBaseCron'
),
'fields' => array(
'namespace' => 'wpubasefields_0_16_0',
'namespace' => 'wpubasefields_0_16_1',
'name' => 'WPUBaseFields'
),
'update' => array(
Expand Down Expand Up @@ -277,6 +277,20 @@ public function init() {
'label' => 'Demo checkbox',
'type' => 'checkbox'
),
'demo_checkbox2' => array(
'group' => 'group_1',
'label' => 'Demo checkbox',
'type' => 'checkbox'
),
'demo_checkbox_text' => array(
'group' => 'group_1',
'toggle-display' => array(
'demo_checkbox2' => 'checked',
'demo_checkbox' => 'checked'
),
'label' => 'Demo checkbox text',
'type' => 'text'
),
'demo2' => array(
'group' => 'group_2',
'label' => 'Demo 2'
Expand Down

0 comments on commit 96730a9

Please sign in to comment.