Skip to content

Commit

Permalink
9.3.3 (#26)
Browse files Browse the repository at this point in the history
- [Widget] Added widget_id to the filter so it can get extra field if needed
- [Widget] Added extra filter to change the arguments
  • Loading branch information
hrsetyono authored Sep 6, 2022
1 parent eb2b3ba commit 6694578
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 17 deletions.
2 changes: 1 addition & 1 deletion edje-wp-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License: MIT
* Author: Pixel Studio
* Author URI: https://pixelstudio.id
* Version: 9.3.2
* Version: 9.3.3
*/

if (!defined('WPINC')) { die; } // exit if accessed directly
Expand Down
57 changes: 47 additions & 10 deletions module-widgets/acf-json/group_62e2560c01b52.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"fields": [
{
"key": "field_62e258ed9034b",
"label": "Has Icon?",
"name": "has_icon",
"type": "true_false",
"label": "Addon",
"name": "addon",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": 0,
Expand All @@ -15,11 +15,16 @@
"class": "",
"id": ""
},
"message": "",
"default_value": 0,
"ui": 1,
"ui_on_text": "",
"ui_off_text": ""
"choices": {
"has-icon": "Has Icon",
"has-image": "Has Image"
},
"allow_null": 1,
"other_choice": 0,
"default_value": "",
"layout": "vertical",
"return_format": "value",
"save_other_choice": 0
},
{
"key": "field_62e2563f32eac",
Expand Down Expand Up @@ -93,7 +98,7 @@
{
"field": "field_62e258ed9034b",
"operator": "==",
"value": "1"
"value": "has-icon"
}
]
],
Expand All @@ -107,6 +112,38 @@
"maxlength": "",
"rows": 4,
"new_lines": ""
},
{
"key": "field_630db7423fc0a",
"label": "Image",
"name": "image",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_62e258ed9034b",
"operator": "==",
"value": "has-image"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": ""
}
]
}
Expand All @@ -129,5 +166,5 @@
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1659004658
"modified": 1661843290
}
1 change: 1 addition & 0 deletions module-widgets/widget--template.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'acf_field' => get_field('acf_field', $widget_id),
];

Expand Down
1 change: 1 addition & 0 deletions module-widgets/widget-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'style' => get_field('style', $widget_id),
'icon' => get_field('icon', $widget_id),
'link' => wp_parse_args(
Expand Down
10 changes: 7 additions & 3 deletions module-widgets/widget-buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'has_icon' => get_field('has_icon', $widget_id),
'widget_id' => $widget_id,
'addon' => get_field('addon', $widget_id),
'buttons' => get_field('buttons', $widget_id),
];

Expand All @@ -27,22 +28,25 @@ function widget($args, $instance) {

function render_widget($data) {
[
'has_icon' => $has_icon,
'addon' => $addon,
'buttons' => $buttons,
] = $data;

ob_start(); ?>

<div class="wp-block-buttons">
<?php foreach ($buttons as $b): ?>
<div class="wp-block-button is-style-<?= $b['style'] ?>">
<div class="wp-block-button is-style-<?= $b['style'] ?> <?= $addon ?>">
<a
class="wp-block-button__link"
href="<?= $b['link']['url'] ?>"
target="<?= $b['link']['target'] ?>"
>
<?php if ($b['svg_icon']): ?>
<?= $b['svg_icon'] ?>

<?php elseif($b['image']): ?>
<img src="<?= $b['image']['sizes']['thumbnail'] ?>">
<?php endif; ?>

<?php if ($b['link']['title']): ?>
Expand Down
11 changes: 8 additions & 3 deletions module-widgets/widget-dark-toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
/**
* Create a dark mode toggle
*/

if (current_theme_supports('h-dark-mode')) {
add_action('wp_body_open', '_h_add_dark_mode_script', 5);
}


class H_DarkToggle extends H_Widget {
function __construct() {
parent::__construct('h_dark_toggle', __('- Dark Mode Toggle'), [
Expand All @@ -10,10 +16,9 @@ function __construct() {
}

function widget($args, $instance) {
add_action('wp_body_open', '_h_add_dark_mode_script', 5);

$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'style' => get_field('style', $widget_id),
'label_light' => '',
'label_dark' => '',
Expand Down Expand Up @@ -63,7 +68,6 @@ function render_widget($data) {
}
}


/**
* Output a script to <head> to check whether dark mode was on or not
*
Expand All @@ -73,6 +77,7 @@ function _h_add_dark_mode_script() { ?>
<script>
(function() { 'use strict';
const darkMode = localStorage.hDarkMode === 'true';
console.log(darkMode);
if (darkMode) {
document.querySelector('body').classList.add('h-is-dark');

Expand Down
1 change: 1 addition & 0 deletions module-widgets/widget-logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'logo' => get_field('logo', $widget_id),
'logo_src' => '',
'tagline' => get_field('tagline', $widget_id),
Expand Down
1 change: 1 addition & 0 deletions module-widgets/widget-recent-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'number_of_posts' => get_field('number_of_posts', $widget_id),
'style' => get_field('style', $widget_id),
'posts' => [],
Expand Down
1 change: 1 addition & 0 deletions module-widgets/widget-separator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function __construct() {
public function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'size' => get_field('footer_size', $widget_id),
'style' => '',
];
Expand Down
1 change: 1 addition & 0 deletions module-widgets/widget-socials.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'items' => get_field('links', $widget_id),
'style' => get_field('link_style', $widget_id),
'color' => get_field('color', $widget_id),
Expand Down
2 changes: 2 additions & 0 deletions module-widgets/widget-toggle-offcanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ function __construct() {
function widget($args, $instance) {
$widget_id = 'widget_' . $args['widget_id'];
$data = [
'widget_id' => $widget_id,
'label' => get_field('label', $widget_id),
'icon' => "<svg xmlns='http://www.w3.org/2000/svg' width='30' height='27' viewBox='0 0 448 512'><path d=\"M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z\"/></svg>",
];

$data = apply_filters('h_widget_toggle_args', $data);
$custom_render = apply_filters('h_widget_toggle', '', $data);

echo $args['before_widget'];
Expand Down

0 comments on commit 6694578

Please sign in to comment.