Skip to content

Commit

Permalink
version 3.1.7 released
Browse files Browse the repository at this point in the history
  • Loading branch information
manchumahara committed Jan 18, 2025
1 parent 5149665 commit 5cf85cc
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 92 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: codeboxr, manchumahara
Tags: currency converter,currency conversion,currency exchange,currency calculator,bitcoin
Requires at least: 5.3
Tested up to: 6.7.1
Stable tag: 3.1.6
Stable tag: 3.1.7
PHP:7.4.*
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -95,6 +95,9 @@ How to install the plugin and get it working.
== Screenshots ==

== Changelog ==
= 3.1.7 =
* [fixed] Fixed miss spelled function name

= 3.1.6 =
* [fixed] Update notification note icon url fixed

Expand Down
2 changes: 1 addition & 1 deletion assets/css/cbcurrencyconverter-admin.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/cbcurrencyconverter-setting.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cbcurrencyconverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Plugin Name: CBX Currency Converter
* Plugin URI: https://codeboxr.com/product/cbx-currency-converter-for-wordpress/
* Description: Currency Converter and rate display
* Version: 3.1.6
* Version: 3.1.7
* Author: codeboxr
* Author URI: https://codeboxr.com
* License: GPL-2.0+
Expand All @@ -24,7 +24,7 @@
}

defined( 'CBCURRENCYCONVERTER_NAME' ) or define( 'CBCURRENCYCONVERTER_NAME', 'cbcurrencyconverter' );
defined( 'CBCURRENCYCONVERTER_VERSION' ) or define( 'CBCURRENCYCONVERTER_VERSION', '3.1.6' );
defined( 'CBCURRENCYCONVERTER_VERSION' ) or define( 'CBCURRENCYCONVERTER_VERSION', '3.1.7' );
defined( 'CBCURRENCYCONVERTER_ROOT_PATH' ) or define( 'CBCURRENCYCONVERTER_ROOT_PATH', plugin_dir_path( __FILE__ ) );
defined( 'CBCURRENCYCONVERTER_ROOT_URL' ) or define( 'CBCURRENCYCONVERTER_ROOT_URL', plugin_dir_url( __FILE__ ) );
defined( 'CBCURRENCYCONVERTER_BASE_NAME' ) or define( 'CBCURRENCYCONVERTER_BASE_NAME', plugin_basename( __FILE__ ) );
Expand Down
8 changes: 6 additions & 2 deletions includes/cbcurrencyconverter-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function cbcurrencyconverter_icon_path() {
* @return string|false The SVG content if found, or false on failure.
* @since 1.0.0
*/
function cbcurrencyconverter_load_svg( $svg_name = '' ) {
function cbcurrencyconverter_load_svg( $svg_name = '', $folder = '' ) {
//note: code partially generated using chatgpt
if ( $svg_name == '' ) {
return '';
Expand All @@ -201,8 +201,12 @@ function cbcurrencyconverter_load_svg( $svg_name = '' ) {
// Sanitize the file name to prevent directory traversal attacks.
$svg_name = sanitize_file_name( $svg_name );

if($folder != ''){
$folder = trailingslashit($folder);
}

// Construct the full file path.
$file_path = $directory . $svg_name . '.svg';
$file_path = $directory. $folder . $svg_name . '.svg';
$file_path = apply_filters('cbcurrencyconverter_svg_file_path', $file_path, $svg_name);

// Check if the file exists.
Expand Down
155 changes: 105 additions & 50 deletions includes/class-cbcurrencyconverter-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,40 @@ class CBCurrencyconverterSetting {
*/
private static $_instance;

/**
* Returns class's instance
*
* @return object|self
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}

return self::$_instance;
}//end method instance

/**
* Cloning is forbidden.
*
* @since 2.1
*/
public function __clone() {
wc_doing_it_wrong( __FUNCTION__, esc_html__( 'Cloning is forbidden.', 'cbcurrencyconverter' ), '2.1' );
}//end method clone

/**
* Unserializing instances of this class is forbidden.
*
* @since 2.1
*/
public function __wakeup() {
wc_doing_it_wrong( __FUNCTION__, esc_html__( 'Unserializing instances of this class is forbidden.', 'cbcurrencyconverter' ), '2.1' );
}//end method wakeup

public function __construct() {

}
}//end constructor


/**
Expand Down Expand Up @@ -154,10 +185,12 @@ function admin_init() {
'sanitize_callback' => isset( $option['sanitize_callback'] ) ? $option['sanitize_callback'] : '',
'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
'multi' => isset( $option['multi'] ) ? intval( $option['multi'] ) : 0,
'fields' => isset( $option['fields'] ) ? $option['fields'] : [],
'type' => $type,
'optgroup' => isset( $option['optgroup'] ) ? intval( $option['optgroup'] ) : 0,
'sortable' => isset( $option['sortable'] ) ? intval( $option['sortable'] ) : 0,
'allow_new' => isset( $option['allow_new'] ) ? intval( $option['allow_new'] ) : 0,
'allow_clear' => isset( $option['allow_clear'] ) ? intval( $option['allow_clear'] ) : 0,//for select2
'inline' => isset( $option['inline'] ) ? absint( $option['inline'] ) : 1,
];

Expand Down Expand Up @@ -204,7 +237,6 @@ function getMissingDefaultValueBySection( $section_id ) {
if ( ! isset( $section_value[ $field['name'] ] ) ) {
$section_value[ $field['name'] ] = isset( $field['default'] ) ? $field['default'] : '';
}

}

return $section_value;
Expand All @@ -215,35 +247,27 @@ function getMissingDefaultValueBySection( $section_id ) {
*
*
* @param array $args
* @param string $element_class
*
* @return string
*/
public function get_field_description( $args ) {
public function get_field_description( $args, $element_class = '' ) {
if ( ! empty( $args['desc'] ) ) {
$desc = sprintf( '<div class="description">%s</div>', $args['desc'] );
$field_id = $args['id'];
$desc_extra_class = ( $element_class != '' ) ? ' description_' . $element_class : '';
$desc = sprintf( '<div class="description description_' . esc_attr( $field_id ) . $desc_extra_class . '">%s</div>', $args['desc'] );
} else {
$desc = '';
}

return $desc;
}//end method get_field_description

/**
* Displays a textarea for a settings field
*
* @param array $args
* @param $value
*
* @return void
*/
function callback_html( $args, $value = null ) {
echo $this->get_field_description( $args );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_html

/**
* Displays heading field using h3
*
* @param array $args
* @param array $args
*
* @return string
*/
Expand All @@ -269,9 +293,64 @@ function callback_subheading( $args ) {
$html = '<h4 class="setting_subheading">' . $args['name'] . '</h4>';
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_subheading

/**
* Displays a textarea for a settings field
*
* @param array $args
* @param $value
*
* @return void
*/
function callback_html( $args, $value = null ) {
echo $this->get_field_description( $args );// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_html

/**
* Displays a text field for a settings field
*
* @param array $args
* @param $value
*
* @return void
*/
function callback_text( $args, $value = null ) {
if ( $value === null ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['default'] ) );
}
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
$type = isset( $args['type'] ) ? $args['type'] : 'text';

$html_id = "{$args['section']}_{$args['id']}";
$html_id = $this->settings_clean_label_for( $html_id );

$html = sprintf( '<input autocomplete="none" onfocus="this.removeAttribute(\'readonly\');" readonly type="%1$s" class="%2$s-text" id="%6$s" name="%3$s[%4$s]" value="%5$s"/>', $type, $size, $args['section'], $args['id'], $value, $html_id );
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end callback_text

/**
* Displays a email field for a settings field
*
* @param array $args settings field args
*/
function callback_email( $args ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['default'] ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
$type = isset( $args['type'] ) ? $args['type'] : 'text';

$html_id = "{$args['section']}_{$args['id']}";
$html_id = $this->settings_clean_label_for( $html_id );

$html = sprintf( '<input autocomplete="none" onfocus="this.removeAttribute(\'readonly\');" readonly type="%1$s" class="%2$s-text" id="%6$s" name="%3$s[%4$s]" value="%5$s"/>', $type, $size, $args['section'], $args['id'], $value, $html_id );
$html .= $this->get_field_description( $args );

echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_email

/**
* Displays an url field for a settings field
*
Expand Down Expand Up @@ -308,7 +387,7 @@ function callback_number( $args, $value = null ) {
$html = sprintf( '<input type="%1$s" class="%2$s-number" id="%10$s" name="%3$s[%4$s]" value="%5$s"%6$s%7$s%8$s%9$s/>', $type, $size, $args['section'], $args['id'], $value, $placeholder, $min, $max, $step, $html_id );
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_number

/**
Expand Down Expand Up @@ -502,7 +581,7 @@ function callback_select( $args ) {

$multi = isset( $args['multi'] ) ? intval( $args['multi'] ) : 0;
$multi_name = ( $multi ) ? '[]' : '';
$multi_attr = ( $multi ) ? 'multiple' : '';
$multi_attr = ( $multi ) ? ' multiple ' : '';

if ( $multi && ! is_array( $value ) ) {
$value = [];
Expand All @@ -515,7 +594,7 @@ function callback_select( $args ) {
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular selecttwo-select';

if ( $args['placeholder'] == '' ) {
$args['placeholder'] = esc_html__( 'Please Select', 'cbcurrencyconverter' );
$args['placeholder'] = esc_html__( 'Please Select', 'cbxwpbookmark' );
}

$html_id = "{$args['section']}_{$args['id']}";
Expand All @@ -526,12 +605,12 @@ function callback_select( $args ) {

if ( isset( $args['optgroup'] ) && $args['optgroup'] ) {
foreach ( $args['options'] as $opt_grouplabel => $option_vals ) {
$html .= '<optgroup label="' . $opt_grouplabel . '">';
$html .= '<optgroup label="' . esc_attr($opt_grouplabel) . '">';

if ( ! is_array( $option_vals ) ) {
$option_vals = [];
} else {
$option_vals = $option_vals;
//$option_vals = $option_vals;
}

foreach ( $option_vals as $key => $val ) {
Expand All @@ -556,7 +635,7 @@ function callback_select( $args ) {
$html .= '</select></div>';
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_select

/**
Expand Down Expand Up @@ -593,15 +672,15 @@ function callback_multiselect( $args ) {
if ( ! is_array( $option_vals ) ) {
$option_vals = [];
} else {
$option_vals = $option_vals;
//$option_vals = $option_vals;
}


foreach ( $option_vals as $key => $val ) {
$selected = in_array( $key, $value ) ? ' selected="selected" ' : '';
$html .= sprintf( '<option value="%s" ' . $selected . '>%s</option>', $key, $val );
}
$html .= '<optgroup>';
$html .= '</optgroup>';
}
} else {

Expand Down Expand Up @@ -685,7 +764,6 @@ function callback_wysiwyg( $args, $value = null ) {
* @param array $args settings field args
*/
function callback_file( $args ) {

$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['default'] ) );
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';

Expand All @@ -705,7 +783,7 @@ function callback_file( $args ) {
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}//end method callback_file

/**
* Displays a color picker field for a settings field
Expand All @@ -716,7 +794,6 @@ function callback_file( $args ) {
* @return void
*/
function callback_color( $args, $value = null ) {

if ( $value === null ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['default'] ) );
}
Expand Down Expand Up @@ -869,29 +946,7 @@ function callback_password( $args, $value = null ) {
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end method callback_password

/**
* Displays a text field for a settings field
*
* @param array $args
* @param $value
*
* @return void
*/
function callback_text( $args, $value = null ) {
if ( $value === null ) {
$value = esc_attr( $this->get_option( $args['id'], $args['section'], $args['default'] ) );
}
$size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
$type = isset( $args['type'] ) ? $args['type'] : 'text';

$html_id = "{$args['section']}_{$args['id']}";
$html_id = $this->settings_clean_label_for( $html_id );

$html = sprintf( '<input autocomplete="none" onfocus="this.removeAttribute(\'readonly\');" readonly type="%1$s" class="%2$s-text" id="%6$s" name="%3$s[%4$s]" value="%5$s"/>', $type, $size, $args['section'], $args['id'], $value, $html_id );
$html .= $this->get_field_description( $args );

echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}//end callback_text

/**
* Displays a textarea for a settings field
Expand Down
Loading

0 comments on commit 5cf85cc

Please sign in to comment.