Skip to content

Commit

Permalink
v1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kousikmukherjee committed Sep 1, 2023
1 parent 2d5f7af commit 4ef3340
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 16 deletions.
6 changes: 3 additions & 3 deletions popup-notices-for-woocommerce.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Plugin Name: Pop-up Notices for WooCommerce
* Plugin Name: Popups for WooCommerce: Add to Cart, Checkout & More
* Plugin URI: https://wordpress.org/plugins/popup-notices-for-woocommerce
* Description: Turn your WooCommerce Notices into Popups
* Version: 1.4.2
* Version: 1.4.3
* Author: WPFactory
* Author URI: https://wpfactory.com
* License: GNU General Public License v3.0
Expand All @@ -12,7 +12,7 @@
* Domain Path: /src/languages
* Copyright: © 2023 WPFactory
* WC requires at least: 3.0.0
* WC tested up to: 7.8
* WC tested up to: 8.0
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand Down
11 changes: 8 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Pop-up Notices for WooCommerce ===
=== Popups for WooCommerce: Add to Cart, Checkout & More ===
Contributors: wpcodefactory,karzin, omardabbas, kousikmukherjeeli
Tags: popup,notices,woocommerce,notice,modal
Requires at least: 4.4
Tested up to: 6.2
Stable tag: 1.4.2
Tested up to: 6.3
Stable tag: 1.4.3
Requires PHP: 5.6.0
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand Down Expand Up @@ -99,6 +99,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

== Changelog ==

= 1.4.3 - 01/09/2023 =
* WC tested up to: 8.0.
* Tested up to: 6.3.
* Dev - open message for free version.

= 1.4.2 - 18/06/2023 =
* WC tested up to: 7.8.
* Tested up to: 6.2.
Expand Down
182 changes: 172 additions & 10 deletions src/php/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Pop-up Notices for WooCommerce (TTT) - Admin Settings
*
* @version 1.3.8
* @version 1.4.3
* @since 1.0.0
* @author WPFactory
*/
Expand All @@ -20,7 +20,7 @@ class Admin_Settings extends \WC_Settings_Page {
/**
* Setup settings class
*
* @version 1.2.4
* @version 1.4.3
* @since 1.0.0
*/
public function __construct() {
Expand All @@ -33,6 +33,7 @@ public function __construct() {
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
add_filter( 'ttt_pnwc_settings_general', array( $this, 'handle_admin_license_settings' ), PHP_INT_MAX );
add_filter( 'ttt_pnwc_settings_compatibility', array( $this, 'handle_admin_license_settings' ), PHP_INT_MAX );
add_filter( 'ttt_pnwc_settings_messages', array( $this, 'handle_admin_license_settings' ), PHP_INT_MAX );

// Allow regex values using allow_raw_values
add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'sanitize_raw_values' ), 10, 3 );
Expand Down Expand Up @@ -99,7 +100,7 @@ public function handle_admin_license_settings( $settings ) {
/**
* Get sections.
*
* @version 1.3.6
* @version 1.4.3
* @since 1.0.0
*
* @return array
Expand All @@ -108,15 +109,15 @@ public function get_sections() {
$sections = array(
'' => __( 'General', 'popup-notices-for-woocommerce' ),
'compatibility' => __( 'Compatibility', 'popup-notices-for-woocommerce' ),
//'messages' => __( 'Messages', 'popup-notices-for-woocommerce' )
'messages' => __( 'Messages', 'popup-notices-for-woocommerce' )
);
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}

/**
* Get settings array.
*
* @version 1.3.8
* @version 1.4.3
* @since 1.0.0
*
* @param string $current_section Optional. Defaults to empty string.
Expand Down Expand Up @@ -448,15 +449,15 @@ public function get_settings( $current_section = '' ) {
// Custom style
array(
'name' => __( 'Custom style', 'popup-notices-for-woocommerce' ),
'premium_section' => true,
'premium_section' => false,
'type' => 'title',
'desc' => __( 'Style the pop-up using the Customizer.', 'popup-notices-for-woocommerce' ),
//'desc' => sprintf( __( 'Style the pop-up using the <a href="%s">Customizer</a>', 'popup-notices-for-woocommerce' ), add_query_arg( array( 'autofocus[panel]' => 'ttt_pnwc' ), admin_url( 'customize.php' ) ) ),
'id' => 'ttt_pnwc_opt_style',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'premium_field' => false,
'id' => 'ttt_pnwc_opt_style_enabled',
'name' => __( 'Enable custom style', 'popup-notices-for-woocommerce' ),
'desc' => sprintf( __( 'Enable pop-up custom style using the <a href="%s">Customizer</a>', 'popup-notices-for-woocommerce' ), add_query_arg( array( 'autofocus[panel]' => 'ttt_pnwc' ), admin_url( 'customize.php' ) ) ),
Expand All @@ -465,23 +466,23 @@ public function get_settings( $current_section = '' ) {
array(
'type' => 'checkbox',
'id' => 'ttt_pnwc_opt_fa',
'premium_field' => true,
'premium_field' => false,
'name' => __( 'Use Font Awesome', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Check if you want to choose icons from FontAwesome', 'popup-notices-for-woocommerce' ),
'default' => 'no'
),
array(
'type' => 'text',
'id' => 'ttt_pnwc_opt_fa_url',
'premium_field' => true,
'premium_field' => false,
'name' => __( 'Font Awesome URL', 'popup-notices-for-woocommerce' ),
'desc_tip' => __( 'Leave it empty if you are already using Font Awesome from somewhere else and do not want to load it twice', 'popup-notices-for-woocommerce' ),
'default' => '//use.fontawesome.com/releases/v5.5.0/css/all.css'
),
array(
'type' => 'textarea',
'id' => 'ttt_pnwc_opt_modal_template',
'premium_field' => true,
'premium_field' => false,
'name' => __( 'Modal template', 'popup-notices-for-woocommerce' ),
'desc' => __( 'HTML template reponsible for displaying the modal', 'popup-notices-for-woocommerce' ),
'css' => 'min-height:223px;width:100%',
Expand Down Expand Up @@ -632,6 +633,110 @@ public function get_settings( $current_section = '' ) {
'id' => 'ttt_pnwc_comp_yithpar_opts',
),
) );
} elseif ( 'messages' === $current_section ) {
$settings = apply_filters( 'ttt_pnwc_settings_messages', array(
array(
'name' => __( 'Messages Customization', 'popup-notices-for-woocommerce' ),
'type' => 'title',
'premium_info' => true,
'desc' => __( 'Customize WooCommerce messages modifying or adding more content after or before them.', 'popup-notices-for-woocommerce' ),
'id' => 'ttt_pnwc_opt_message_customization',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_enable',
'name' => __( 'Customize Messages', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Customize Notice messages', 'popup-notices-for-woocommerce' ),
'default' => 'no',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_smart_content',
'name' => __( 'Smart Additional Content', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Additional Content will be visible only inside the Popup', 'popup-notices-for-woocommerce' ),
'default' => 'yes',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_shortcodes',
'name' => __( 'Shortcodes', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Allow Shortcodes on Modified HTML Content', 'popup-notices-for-woocommerce' ),
'checkboxgroup' => 'start',
'default' => 'yes',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_shortcodes_original_content',
'name' => __( 'Allow Shortcodes', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Allow Shortcodes on Original HTML Content', 'popup-notices-for-woocommerce' ),
'desc_tip' => sprintf( __( 'You can use the %s shortcode to get dynamic messages from any filter you wish. e.g. %s.', 'popup-notices-for-woocommerce' ), '<code>' . '[ttt_pnwc_get_message]' . '</code>', '<code>' . '[ttt_pnwc_get_message filter="wc_add_to_cart_message_html"]' . '</code>' ),
'checkboxgroup' => 'end',
'default' => 'yes',
),
array(
'type' => 'checkbox',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_gettext',
'name' => __( 'Customize Translated Text', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Try to customize the translated text with <code>gettext</code> filter', 'popup-notices-for-woocommerce' ),
'desc_tip'=> __( 'Only enable it if the text you want to customize is not getting modified, as it\'s slower and does not allow HTML.', 'popup-notices-for-woocommerce' ) . '<br />' . __( 'The correct way of creating a Notice in WooCommerce is using the <code>wc_add_notice()</code> or <code>WP_Error::add()</code> functions.', 'popup-notices-for-woocommerce' ) . '<br />' . __( 'If the message you want to customize is not getting modified, probably it was not created with these functions.', 'popup-notices-for-woocommerce' ),
'default' => 'no',
),
array(
'type' => 'text',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_content_tag',
'name' => __( 'Additional Content Tag', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Additional Content HTML tag', 'popup-notices-for-woocommerce' ),
'default' => 'div',
),
array(
'type' => 'number',
'premium_field' => true,
'id' => 'ttt_pnwc_opt_message_customization_amount',
'name' => __( 'Total Messages', 'popup-notices-for-woocommerce' ),
'desc' => __( 'Total number of messages you want to customize', 'popup-notices-for-woocommerce' ),
'custom_attributes' => array( 'min' => 1 ),
'default' => 1,
),
array(
'type' => 'sectionend',
'premium_section' => true,
'id' => 'ttt_pnwc_opt_message_customization'
),
array(
'name' => __( 'Template Variables', 'popup-notices-for-woocommerce' ),
'type' => 'title',
'premium_info' => true,
'desc' => __( 'You can use some template variables on <strong>Modified HTML Content</strong> option, but some of them may only work according to the context.', 'popup-notices-for-woocommerce' ).'<br />'.$this->get_template_variables_str(),
'id' => 'ttt_pnwc_opt_message_variables',
),
array(
'type' => 'sectionend',
'premium_section' => true,
'id' => 'ttt_pnwc_opt_message_variables'
),
array(
'name' => __( 'Examples', 'popup-notices-for-woocommerce' ),
'type' => 'title',
'premium_info' => true,
'desc' => __( 'Examples you can use on <strong>Original HTML Content</strong>.', 'popup-notices-for-woocommerce' ) .
$this->get_examples_str( array(
sprintf( __( 'Use %s to modify the %s message (%s)', 'popup-notices-for-woocommerce' ), '<code>' . '[ttt_pnwc_get_message filter="wc_add_to_cart_message_html"]' . '</code>', '<strong>' . __( 'Add to cart', 'popup-notices-for-woocommerce' ) . '</strong>', '<strong>' . __( '%s has been added to your cart.', 'woocommerce' ) . '</strong>' ),
sprintf( __( 'Use %s to modify the %s message (%s)', 'popup-notices-for-woocommerce' ), '<code>' . '[ttt_pnwc_get_message filter="woocommerce_cart_product_cannot_add_another_message"]' . '</code>', '<strong>' . __( 'Cannot add another', 'popup-notices-for-woocommerce' ) . '</strong>', '<strong>' . __( 'You cannot add another "%s" to your cart.', 'woocommerce' ) . '</strong>' )
) ),
'id' => 'ttt_pnwc_opt_message_examples',
),
array(
'type' => 'sectionend',
'premium_section' => true,
'id' => 'ttt_pnwc_opt_message_examples'
)
) );
} else {
$settings = apply_filters( "ttt_pnwc_settings_{$current_section}", array() );
}
Expand Down Expand Up @@ -678,5 +783,62 @@ public function save() {
$settings = $this->get_settings( $current_section );
\WC_Admin_Settings::save_fields( $settings );
}

/**
* get_template_variables.
*
* @version 1.4.3
* @since 1.4.3
*
* @return array
*/
function get_template_variables() {
return array(
'product_id' => __( 'Product ID', 'popup-notices-for-woocommerce' ),
'post_title' => __( 'Post or Product title', 'popup-notices-for-woocommerce' ),
'cart_permalink' => __( 'Cart permalink', 'popup-notices-for-woocommerce' ),
'myaccount_permalink' => __( 'My account permalink', 'popup-notices-for-woocommerce' ),
'shop_permalink' => __( 'Shop permalink', 'popup-notices-for-woocommerce' ),
'checkout_permalink' => __( 'Checkout permalink', 'popup-notices-for-woocommerce' ),
'terms_permalink' => __( 'Terms permalink', 'popup-notices-for-woocommerce' ),
);
}

/**
* get_template_variables_str.
*
* @version 1.4.3
* @since 1.4.3
*
* @return string
*/
function get_template_variables_str(){
$variables = $this->get_template_variables();
$output = '<ul class="ttt-pnwc-list-a">';
foreach ($variables as $key=>$value){
$output.='<li><strong>{{'.$key.'}}</strong>: '.$value.'</li>';
}
$output.='</ul>';
return $output;
}

/**
* get_examples_str.
*
* @version 1.4.3
* @since 1.4.3
*
* @param $examples_array
*
* @return string
*/
function get_examples_str( $examples_array ) {
$output = '<ul class="ttt-pnwc-list-a">';
foreach ( $examples_array as $value ) {
$output .= '<li>' . $value . '</li>';
}
$output .= '</ul>';
return $output;
}
}
}

0 comments on commit 4ef3340

Please sign in to comment.