Skip to content

Commit

Permalink
save the settings
Browse files Browse the repository at this point in the history
  • Loading branch information
amirition committed Feb 7, 2024
1 parent 24bb754 commit c8a663e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
32 changes: 6 additions & 26 deletions src/Admin/Settings_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Plugin\Plugin;
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable;
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Util;
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Util as Lib_Util;
use Barn2\Plugin\WC_Product_Tabs_Free\Util;

/**
* The settings page.
Expand Down Expand Up @@ -45,7 +46,7 @@ public function __construct( Plugin $plugin ) {
* {@inheritdoc}
*/
public function is_required() {
return Util::is_admin();
return Lib_Util::is_admin();
}

/**
Expand Down Expand Up @@ -96,8 +97,8 @@ public function support_links(): void {
printf(
'<p>%s | %s | %s</p>',
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
Util::format_link( $this->plugin->get_documentation_url(), __( 'Documentation', 'woocommerce-product-tabs' ), true ),
Util::format_link( $this->plugin->get_support_url(), __( 'Support', 'woocommerce-product-tabs' ), true ),
Lib_Util::format_link( $this->plugin->get_documentation_url(), __( 'Documentation', 'woocommerce-product-tabs' ), true ),
Lib_Util::format_link( $this->plugin->get_support_url(), __( 'Support', 'woocommerce-product-tabs' ), true ),
sprintf(
'<a class="barn2-wiz-restart-btn" href="%s">%s</a>',
add_query_arg( [ 'page' => $this->plugin->get_slug() . '-setup-wizard' ], admin_url( 'admin.php' ) ),
Expand Down Expand Up @@ -185,7 +186,7 @@ function register_plugin_option_fields()
*/
function disable_content_filter()
{
$disable_content_filter = $this->get_option( 'disable_content_filter' );
$disable_content_filter = Util::get_option( 'disable_content_filter' );
?>
<label for="disable_content_filter">
<input type="checkbox" name="wpt_options[disable_content_filter]" id="disable_content_filter" value="1" <?php checked( 1, $disable_content_filter ); ?> />
Expand Down Expand Up @@ -263,25 +264,4 @@ function admin_product_tabs_options_page()
$this->get_settings_page_footer();
}

/**
* Get plugin option.
*
* @since 1.0.0
*/
function get_option( $key )
{
if ( empty( $key ) ) {
return;
}

$plugin_options = wp_parse_args( (array) get_option( 'wpt_options' ), [ 'description', 'hide_description', 'info', 'hide_info', 'review', 'hide_review', 'search_by_tabs', 'enable_accordion', 'accordion_shown_size', 'description_priority', 'info_priority', 'review_priority', 'license' ] );

$value = null;

if ( isset( $plugin_options[ $key ] ) ) {
$value = $plugin_options[ $key ];
}

return $value;
}
}
13 changes: 6 additions & 7 deletions src/Product_Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Registerable;
use Barn2\Plugin\WC_Product_Tabs_Free\Dependencies\Lib\Service;
use WP_Embed;

/**
* Show the tabs on the single product page
Expand Down Expand Up @@ -164,7 +165,7 @@ public function product_tabs_filter_content( $content ) {
$content = function_exists( 'do_shortcode' ) ? do_shortcode( $content ) : $content;

if ( class_exists( 'WP_Embed' ) ) {
$embed = new WP_Embed;
$embed = new \WP_Embed();
$content = method_exists( $embed, 'autoembed' ) ? $embed->autoembed( $content ) : $content;
}

Expand Down Expand Up @@ -196,14 +197,12 @@ public function get_filter_content( $content ) {
* @since 2.0.2
*/
public function enable_the_content_filter() {
$disable_the_content_filter = get_option( 'wpt_disable_content_filter' );
$disable_the_content_filter = Util::get_option( 'disable_content_filter' );
$output = false;

if ( empty( $disable_the_content_filter ) ) {
$disable_the_content_filter = 'no';
}

if ( 'yes' === $disable_the_content_filter ) {
if ( empty( $disable_the_content_filter ) || $disable_the_content_filter !== '1' ) {
$output = false;
} else {
$output = true;
}

Expand Down
21 changes: 21 additions & 0 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,25 @@ public static function is_tab_overridden( $tab_key, $product_id ) {
return 'yes' === $override_meta;
}

/**
* Get plugin option.
*
* @since 1.0.0
*/
public static function get_option( $key )
{
if ( empty( $key ) ) {
return;
}

$plugin_options = wp_parse_args( (array) get_option( 'wpt_options' ), [ 'description', 'hide_description', 'info', 'hide_info', 'review', 'hide_review', 'search_by_tabs', 'enable_accordion', 'accordion_shown_size', 'description_priority', 'info_priority', 'review_priority', 'license' ] );

$value = null;

if ( isset( $plugin_options[ $key ] ) ) {
$value = $plugin_options[ $key ];
}

return $value;
}
}

0 comments on commit c8a663e

Please sign in to comment.