Skip to content

Commit

Permalink
New: comply with WP Plugin Check standards (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadNateqi authored Oct 30, 2024
1 parent 73c8b1a commit c36a38b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 53 deletions.
59 changes: 29 additions & 30 deletions includes/class-wciep-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function iepp_add_page() {
* Add settings link to plugins page
*/
public function improvedexternalproducts_add_settings_link( $links ) {
$settings_link = '<a href="options-general.php?page=iepp_options_page">'. __( 'Settings', 'woocommerce' ) . '</a>';
$settings_link = '<a href="options-general.php?page=iepp_options_page">'. __( 'Settings', 'woocommerce-improved-external-products' ) . '</a>';
array_push( $links, $settings_link );
return $links;
}
Expand Down Expand Up @@ -246,18 +246,18 @@ public function improvedexternalproducts_options_do_page() {
?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h2><?php _e('Improved External Products','woocommerce-improved-external-products') ?></h2>
<h2><?php esc_html_e('Improved External Products','woocommerce-improved-external-products') ?></h2>

<?php if (!class_exists('ImprovedExternalProductsPro')){ ?>
<div class="improved-external-products-pro-ad">
<img src="<?php echo plugins_url( 'assets/images/wpo-helper.png', dirname(__FILE__) ); ?>" class="wpo-helper">
<h3><?php _e( 'Supercharge Improved External Products with the following features:', 'woocommerce-improved-external-products' ); ?></h3>
<img src="<?php echo esc_url( plugins_url( 'assets/images/wpo-helper.png', dirname(__FILE__) ) ); ?>" class="wpo-helper">
<h3><?php esc_html_e( 'Supercharge Improved External Products with the following features:', 'woocommerce-improved-external-products' ); ?></h3>
<ul>
<li><?php _e('Open in new tab or current tab on a product level.','woocommerce-improved-external-products') ?></li>
<li><?php _e('Open in new tab or current tab on a category level.','woocommerce-improved-external-products') ?></li>
<li><?php _e('Setup variable external products.','woocommerce-improved-external-products') ?></li>
<li><?php esc_html_e('Open in new tab or current tab on a product level.','woocommerce-improved-external-products') ?></li>
<li><?php esc_html_e('Open in new tab or current tab on a category level.','woocommerce-improved-external-products') ?></li>
<li><?php esc_html_e('Setup variable external products.','woocommerce-improved-external-products') ?></li>
</ul>
<a href="https://wpovernight.com/downloads/improved-external-products-pro/" target="_blank"class="button button-primary"><?php _e("Get Improved External Products Pro!", 'woocommerce-improved-external-products'); ?></a>
<a href="https://wpovernight.com/downloads/improved-external-products-pro/" target="_blank"class="button button-primary"><?php esc_html_e("Get Improved External Products Pro!", 'woocommerce-improved-external-products'); ?></a>
</div>
<style>
.improved-external-products-pro-ad {
Expand Down Expand Up @@ -314,8 +314,8 @@ public function improvedexternalproducts_options_do_page() {
submit_button();
?>
<div style="margin-top:20px;margin-bottom:40px">
<h2><?php _e( 'Having Trouble?','woocommerce-improved-external-products' ); ?></h2>
<p><?php _e( 'Email support@wpovernight.com and we\'ll answer your question as quickly as possible.','woocommerce-improved-external-products' ); ?></p>
<h2><?php esc_html_e( 'Having Trouble?','woocommerce-improved-external-products' ); ?></h2>
<p><?php esc_html_e( 'Email support@wpovernight.com and we\'ll answer your question as quickly as possible.','woocommerce-improved-external-products' ); ?></p>
</div>
</form>
<script type="text/javascript">
Expand Down Expand Up @@ -369,7 +369,7 @@ public function text_element_callback( $args ) {
$html = '<div style="display:inline-block; position:relative;">'.$html.'</div>';
}

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

/**
Expand Down Expand Up @@ -409,7 +409,7 @@ public function textarea_element_callback( $args ) {
$html = '<div style="display:inline-block; position:relative;">'.$html.'</div>';
}

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

/**
Expand Down Expand Up @@ -445,7 +445,7 @@ public function select_element_callback( $args ) {
$html .= sprintf( '<p class="description">%s</p>', wp_kses_post( $args['description'] ) );
}

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

/**
Expand Down Expand Up @@ -485,9 +485,8 @@ public function multiple_select_element_callback( $args ) {
}
$html .= '<br />';
}


echo $html;

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

/**
Expand All @@ -500,28 +499,28 @@ public function multiple_select_element_callback( $args ) {
public function checkbox_element_callback( $args ) {
$menu = $args['menu'];
$id = $args['id'];

$options = get_option( $menu );

if ( isset( $options[$id] ) ) {
$current = $options[$id];
} else {
$current = isset( $args['default'] ) ? $args['default'] : '';
}

if(!class_exists('ImprovedExternalProductsPro')){
$disabled = (isset( $args['disabled'] )) ? ' disabled' : '';
} else {
$disabled = '';
}
$html = sprintf( '<input type="checkbox" id="%1$s" name="%2$s[%1$s]" value="1"%3$s %4$s/>', esc_attr( $id ), esc_attr( $menu ), checked( 1, $current, false ), esc_attr( $disabled ) );

// Displays option description.
if ( isset( $args['description'] ) ) {
$html .= sprintf( '<p class="description">%s</p>', wp_kses_post( $args['description'] ) );
}
echo $html;

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

/**
Expand Down Expand Up @@ -563,7 +562,7 @@ public function radio_element_callback( $args ) {
$html = '<div style="display:inline-block; position:relative;">'.$html.'</div>';
}

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

/**
Expand All @@ -574,25 +573,25 @@ public function radio_element_callback( $args ) {
public function icons_radio_element_callback( $args ) {
$menu = $args['menu'];
$id = $args['id'];

$options = get_option( $menu );

if ( isset( $options[$id] ) ) {
$current = $options[$id];
} else {
$current = isset( $args['default'] ) ? $args['default'] : '';
}
$icons = '';
$radios = '';

foreach ( $args['options'] as $key => $iconnumber ) {
$icons .= sprintf( '<td style="padding-bottom:0;font-size:16pt;" align="center"><label for="%1$s[%2$s][%3$s]"><i class="improvedexternalproducts-icon-shopping-cart-%4$s"></i></label></td>', esc_attr( $menu ), esc_attr( $id ), esc_attr( $key ), esc_attr( $iconnumber ) );
$radios .= sprintf( '<td style="padding-top:0" align="center"><input type="radio" class="radio" id="%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s"%4$s /></td>', esc_attr( $menu ), esc_attr( $id ), esc_attr( $key ), checked( $current, $key, false ) );
}
$html = '<table><tr>'.$icons.'</tr><tr>'.$radios.'</tr></table>';
$html .= '<p class="description"><i>'. __('<strong>Please note:</strong> you need to open your website in a new tab/browser window after updating the cart icon for the change to be visible!','woocommerce-improved-external-products').'</p>';
echo $html;

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

public function multicheckbox_element_callback( $args ) {
Expand All @@ -619,8 +618,8 @@ public function multicheckbox_element_callback( $args ) {
$html .= '<div style="position:absolute; left:0; right:0; top:0; bottom:0; background-color:white; -moz-opacity: 0; opacity:0;filter: alpha(opacity=0);" class="hidden-input"></div>';
$html = '<div style="display:inline-block; position:relative;">'.$html.'</div>';
}
echo $html;

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

/**
Expand Down Expand Up @@ -662,7 +661,7 @@ public function improvedexternalproducts_options_validate( $input ) {
if($key == 'custom_single_button_html' || $key == 'variation_custom_single_button_html'){
$output[$key] = $input[$key];
} else {
$output[$key] = strip_tags( stripslashes( $input[$key] ) );
$output[$key] = wp_strip_all_tags( stripslashes( $input[$key] ) );
}
}
//print_r($output);
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Improved External Products for WooCommerce ===
Contributors: pomegranate, jprummer, alexmigf, yordansoares, kluver, dpeyou, dwpriv
Donate link: https://www.wpovernight.com/
Tags: woocommerce, affiliate, external product, link, new tab, external/affiliate
Tags: woocommerce, affiliate, external product, link, external/affiliate
Requires at least: 3.5
Tested up to: 6.6
Stable tag: 1.6.5
Expand Down
51 changes: 29 additions & 22 deletions wc-improved-external-products.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Improved External Products for WooCommerce
* Plugin URI: https://wordpress.org/plugins/woocommerce-improved-external-products/
* Plugin URI: https://wpovernight.com/downloads/improved-external-products-pro/
* Description: Opens External/Affiliate products in a new tab.
* Version: 1.6.5
* Author: WP Overnight
Expand Down Expand Up @@ -106,22 +106,25 @@ public function woocommerce_hpos_compatible() {
*/
public function go_pro_notice() {
$screen = $this->order_util->custom_order_table_screen();

if ( ( isset( $_REQUEST['page'] ) && 'iepp_options_page' != $_REQUEST['page'] ) || ! in_array( $screen, array( 'shop_order', 'edit-shop_order', 'woocommerce_page_wc-orders', 'edit-product', 'product' ) ) ) {

if (
( isset( $_REQUEST['page'] ) && 'iepp_options_page' !== $_REQUEST['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended
! in_array( $screen, array( 'shop_order', 'edit-shop_order', 'woocommerce_page_wc-orders', 'edit-product', 'product' ) )
) {
return;
}

if ( get_option( 'wpo_iepp_pro_notice_dismissed' ) !== false || get_option( 'iepp_go_pro_notice' ) == 'gopro' ) {
if ( get_option( 'wpo_iepp_pro_notice_dismissed' ) !== false || 'gopro' === get_option( 'iepp_go_pro_notice' ) ) {
return;
} else {
if ( isset( $_GET['wpo_iepp_dismis_pro'] ) ) {
if ( isset( $_GET['wpo_iepp_dismis_pro'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'wpo_iepp_dismis_pro_notice' ) ) {
update_option( 'wpo_iepp_pro_notice_dismissed', true );
return;
}

// keep track of how many days this notice is show so we can remove it after 7 days
$notice_shown_on = get_option( 'wpo_iepp_pro_notice_shown', array() );
$today = date('Y-m-d');
$today = gmdate('Y-m-d');
if ( !in_array($today, $notice_shown_on) ) {
$notice_shown_on[] = $today;
update_option( 'wpo_iepp_pro_notice_shown', $notice_shown_on );
Expand All @@ -134,38 +137,42 @@ public function go_pro_notice() {

?>
<div class="notice notice-info is-dismissible wpo-iepp-pro-notice">
<h3><?php _e( 'Thank you for using Improved External Products! Check out our pro version:', 'woocommerce-improved-external-products' ); ?></h3>
<h3><?php esc_html_e( 'Thank you for using Improved External Products! Check out our pro version:', 'woocommerce-improved-external-products' ); ?></h3>
<ul class="ul-square">
<li><?php _e( 'Ability to open external products in a new tab from product archives', 'woocommerce-improved-external-products' ) ?></li>
<li><?php _e( 'Set tab action on a per-product basis', 'woocommerce-improved-external-products' ) ?></li>
<li><?php _e( 'Set tab action on a product category basis', 'woocommerce-improved-external-products' ) ?></li>
<li><?php _e( 'Priority Customer Support', 'woocommerce-improved-external-products' ) ?></li>
<li><?php esc_html_e( 'Ability to open external products in a new tab from product archives', 'woocommerce-improved-external-products' ) ?></li>
<li><?php esc_html_e( 'Set tab action on a per-product basis', 'woocommerce-improved-external-products' ) ?></li>
<li><?php esc_html_e( 'Set tab action on a product category basis', 'woocommerce-improved-external-products' ) ?></li>
<li><?php esc_html_e( 'Priority Customer Support', 'woocommerce-improved-external-products' ) ?></li>
</ul>
<p><a href="https://wpovernight.com/downloads/improved-external-products-pro/" target="_blank"><?php _e( 'Click here to go Pro now!', 'woocommerce-improved-external-products' ) ?></a></p>
<p><a href="<?php echo esc_url( add_query_arg( 'wpo_iepp_dismis_pro', true ) ); ?>" class="wpo-iepp-dismiss"><?php _e( 'Dismiss this notice', 'woocommerce-improved-external-products' ); ?></a></p>
<p><a href="https://wpovernight.com/downloads/improved-external-products-pro/" target="_blank"><?php esc_html_e( 'Click here to go Pro now!', 'woocommerce-improved-external-products' ) ?></a></p>
<p><a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wpo_iepp_dismis_pro', true ), 'wpo_iepp_dismis_pro_notice' ) ); ?>" class="wpo-iepp-dismiss"><?php esc_html_e( 'Dismiss this notice', 'woocommerce-improved-external-products' ); ?></a></p>
</div>
<?php
}
}

public function backend_scripts_styles() {
$screen = $this->order_util->custom_order_table_screen();

if ( ( isset( $_REQUEST['page'] ) && 'iepp_options_page' == $_REQUEST['page'] ) || in_array( $screen, array( 'shop_order', 'edit-shop_order', 'woocommerce_page_wc-orders', 'edit-product', 'product' ) ) ) {

if (
( isset( $_REQUEST['page'] ) && 'iepp_options_page' === $_REQUEST['page'] ) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended
in_array( $screen, array( 'shop_order', 'edit-shop_order', 'woocommerce_page_wc-orders', 'edit-product', 'product' ) )
) {
wp_enqueue_script(
'wpo-iepp-admin',
untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/assets/js/admin-script.js',
array( 'jquery' ),
WC_IEP_VERSION
WC_IEP_VERSION,
true
);
}
}

public function iepp_redirect() {
if (get_option('iepp_do_activation_redirect', false)) {
delete_option('iepp_do_activation_redirect');
if(!isset($_GET['activate-multi'])){
wp_redirect(IEPP_SETTINGS_URL);
if ( get_option( 'iepp_do_activation_redirect', false ) ) {
delete_option( 'iepp_do_activation_redirect' );
if ( ! isset( $_GET['activate-multi'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
wp_redirect( IEPP_SETTINGS_URL );
}
}
}
Expand Down Expand Up @@ -193,7 +200,7 @@ public function iepp_external_add_to_cart() {

$target = $this->determine_link_target( $product->get_id() );
$price_html = $product->get_price_html();
if ( $target == true ) {
if ( $target ) {
$target = '_blank';
} else {
$target = '_self';
Expand All @@ -209,7 +216,7 @@ public function iepp_external_add_to_cart() {
$html = str_replace( '{target}', esc_attr( $target ), $html );
$html = str_replace( '{button_text}', esc_html( $button_text ), $html );
$html = str_replace( '{price_html}', esc_html( $price_html ), $html );
echo $html;
echo wp_kses_post( $html );
} else {
?>
<p class="cart">
Expand Down

0 comments on commit c36a38b

Please sign in to comment.