Skip to content

Commit

Permalink
🚀 release v4.0.0, improve php code
Browse files Browse the repository at this point in the history
  • Loading branch information
daomapsieucap committed Apr 21, 2022
1 parent 0887f8c commit 00cf0d7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

## Changelog

### v4.0.0 - 2022-04-20
### v4.0.0 - 2022-04-21

- New: Mass upgrade with VueJS and a brand-new layout.

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div align="center">

<img width="100px" src="https://ps.w.org/acf-icomoon/assets/icon.svg" align="center" alt="Icomoon for Advanced Custom Fields" />

<h1 align="center" style="border:none; padding:0;">IcoMoon for Advanced Custom Fields</h1>

<p align="center">A new ACF field that allows to select icon from <a href="https://icomoon.io" target="_blank">IcoMoon</a> json.</p>

<p align="center">
Expand All @@ -22,7 +22,6 @@

</div>


## Getting started

### Download
Expand All @@ -36,11 +35,11 @@ from [releases](https://github.com/viivue/acf-icomoon/releases)

Go to Field Groups > Create new Field and choose Icomoon Type in Content Group.

![Screenshot 1](https://ps.w.org/acf-icomoon/assets/screenshot-3.png)
![Screenshot 3](https://ps.w.org/acf-icomoon/assets/screenshot-3.png)

How it looks in the page

![Screenshot 2](https://ps.w.org/acf-icomoon/assets/screenshot-1.png)
![Screenshot 1](https://ps.w.org/acf-icomoon/assets/screenshot-1.png)
![Screenshot 2](https://ps.w.org/acf-icomoon/assets/screenshot-2.png)

## Compatibility
Expand Down
13 changes: 5 additions & 8 deletions acf-icomoon.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Definitions
*/

define('ACFICOMOON_VERSION', '4.0.0');
const ACFICOMOON_VERSION = '4.0.0';
define("ACFICOMOON_DIR", plugin_dir_path(__FILE__));
define("ACFICOMOON_ASSETS_URL", plugin_dir_url(__FILE__) . 'assets/');
define("ACFICOMOON_STYLESHEET_DIR", get_stylesheet_directory());
Expand All @@ -41,15 +41,12 @@
include_once(ACFICOMOON_DIR . 'includes/acf-icomoon.php');

/**
* Init Functions
* WPBakery Page Builder
*/

add_action('init', 'viivue_icomoon_init');
function viivue_icomoon_init(){
// WPBakery Page Builder Param
if(defined('WPB_VC_VERSION')){
include_once(ACFICOMOON_DIR . 'includes/js_composer.php');
}
add_action('vc_before_init', 'viivue_icomoon_vc_param');
function viivue_icomoon_vc_param(){
include_once(ACFICOMOON_DIR . 'compatibility/js_composer.php');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
== Changelog ==

= 4.0.0 =
*Release Date - 20 April 2022*
*Release Date - 21 April 2022*

- New: Mass upgrade with VueJS and a brand-new layout.

Expand Down
40 changes: 20 additions & 20 deletions includes/js_composer.php → compatibility/js_composer.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php
/**
* VC Icomoon Param
*/

vc_add_shortcode_param('icomoon_class', 'viivue_js_composer_icomoon');
function viivue_js_composer_icomoon($settings, $value){
$acf_icomoon = new ViiVue_ACF_Field_Icomoon();

$json_path = file_get_contents(ACFICOMOON_STYLESHEET_DIR . "/assets/fonts/selection.json");
$icon_array = $acf_icomoon->viivue_get_icomoon_json($json_path);
$type = viivue_array_key_exists("type", $settings);
$param_name = viivue_array_key_exists("param_name", $settings);
$value = esc_attr($value);
$input_html = '<input name="' . esc_attr($param_name) . '" class="hidden wpb_vc_param_value wpb-textinput ' . esc_attr($param_name) . ' ' . esc_attr($type) . '_field" type="text" v-model="selected.icon_class" data-icomoon-input/>';

$html = $acf_icomoon->viivue_icomoon_select_html($icon_array, $value, $input_html, true);
$html .= '<script>jsComposerAfterElementRender(document.querySelector(".vc_ui-panel.vc_active"));</script>';

return $html;
<?php
/**
* VC Icomoon Param
*/

vc_add_shortcode_param('icomoon_class', 'viivue_js_composer_icomoon');
function viivue_js_composer_icomoon($settings, $value){
$acf_icomoon = new ViiVue_ACF_Field_Icomoon();

$json_path = file_get_contents(ACFICOMOON_STYLESHEET_DIR . "/assets/fonts/selection.json");
$icon_array = $acf_icomoon->viivue_get_icomoon_json($json_path);
$type = viivue_array_key_exists("type", $settings);
$param_name = viivue_array_key_exists("param_name", $settings);
$value = esc_attr($value);
$input_html = '<input name="' . esc_attr($param_name) . '" class="hidden wpb_vc_param_value wpb-textinput ' . esc_attr($param_name) . ' ' . esc_attr($type) . '_field" type="text" v-model="selected.icon_class" data-icomoon-input/>';

$html = $acf_icomoon->viivue_icomoon_select_html($icon_array, $value, $input_html, true);
$html .= '<script>jsComposerAfterElementRender(document.querySelector(".vc_ui-panel.vc_active"));</script>';

return $html;
}
1 change: 1 addition & 0 deletions includes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* Get specific item from array with callback default value
*/

if(!function_exists('viivue_array_key_exists')){
function viivue_array_key_exists($key, $array, $default = ''){
if($array && is_array($array)){
Expand Down
10 changes: 5 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: viivue, daomapsieucap, phucbm
Tags: Advanced Custom Fields, ACF, Icomoon
Requires at least: 4.7
Tested up to: 5.8
Requires PHP: 5.6
Tested up to: 5.9.3
Requires PHP: 7.0
Stable tag: 4.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -17,7 +17,7 @@ This ACF field type is compatible with:

== Installation ==

1. Download Support For Icomoon with Advanced Custom Fields plugin
1. Download "Support For Icomoon with Advanced Custom Fields" plugin
2. Upload it to your wp-content/plugins directory
3. Go to CMS admin plugins list and activate the plugin
4. Go to Field Groups > Create new Field and choose Icomoon Type in Content Group.
Expand All @@ -26,11 +26,11 @@ This ACF field type is compatible with:

1. New field type Icomoon in ACF
2. Select icon
3. Additional field for WPBakery (formerly Visual Composer)
3. Additional field for WPBakery Page Builder plugin (formerly Visual Composer)

== Changelog ==

= 4.0.0 =
*Release Date - 20 April 2022*
*Release Date - 21 April 2022*

- New: Mass upgrade with VueJS and a brand-new layout.

0 comments on commit 00cf0d7

Please sign in to comment.