| @@ -5,51 +5,50 @@ | ||
| 5 | 5 | * This file is read by WordPress to generate the plugin information in the plugin |
| 6 | 6 | * admin area. This file also includes all of the dependencies used by the plugin, |
| 7 | 7 | * registers the activation and deactivation functions, and defines a function |
| 8 | 8 | * that starts the plugin. |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * Woo Additional Terms is free software: you can redistribute it and/or modify |
| 11 | 11 | * it under the terms of the GNU General Public License as published by |
| 12 | 12 | * the Free Software Foundation, either version 2 of the License, or |
| 13 | 13 | * any later version. |
| 14 | 14 | * |
| 15 | - * @link https://www.mypreview.one | |
| 16 | - * @since 1.2.1 | |
| 17 | - * @package woo-additional-terms | |
| 15 | + * @link https://www.mypreview.one | |
| 16 | + * @since 1.2.0 | |
| 17 | + * @package woo-additional-terms | |
| 18 | + * @author MyPreview (Github: @mahdiyazdani, @mypreview) | |
| 19 | + * @copyright © 2015 - 2019 MyPreview. All Rights Reserved. | |
| 18 | 20 | * |
| 19 | 21 | * @wordpress-plugin |
| 20 | - * Plugin Name: Woo Additional Terms | |
| 21 | - * Plugin URI: https://www.mypreview.one | |
| 22 | - * Description: Add additional terms and condition checkbox to the WooCommerce checkout. | |
| 23 | - * Version: 1.2.1 | |
| 24 | - * Author: MyPreview | |
| 25 | - * Author URI: https://www.mypreview.one | |
| 26 | - * License: GPL-2.0 | |
| 27 | - * License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
| 28 | - * Text Domain: woo-additional-terms | |
| 29 | - * Domain Path: /languages | |
| 30 | - * WC requires at least: 3.4.0 | |
| 31 | - * WC tested up to: 4.0.1 | |
| 22 | + * Plugin Name: Woo Additional Terms | |
| 23 | + * Plugin URI: https://www.mypreview.one | |
| 24 | + * Description: Add additional terms and condition checkbox to the WooCommerce checkout. | |
| 25 | + * Version: 1.2.0 | |
| 26 | + * Author: MyPreview | |
| 27 | + * Author URI: https://www.mypreview.one | |
| 28 | + * License: GPL-2.0 | |
| 29 | + * License URI: http://www.gnu.org/licenses/gpl-2.0.txt | |
| 30 | + * Text Domain: woo-additional-terms | |
| 31 | + * Domain Path: /languages | |
| 32 | + * WC requires at least: 3.4.0 | |
| 33 | + * WC tested up to: 3.8.1 | |
| 32 | 34 | */ |
| 33 | - | |
| 34 | 35 | // If this file is called directly, abort. |
| 35 | 36 | if ( ! defined( 'WPINC' ) ) { |
| 36 | - wp_die(); | |
| 37 | + wp_die(); | |
| 37 | 38 | } // End If Statement |
| 38 | 39 | |
| 39 | 40 | /** |
| 40 | 41 | * Gets the path to a plugin file or directory. |
| 41 | - * | |
| 42 | - * @see https://codex.wordpress.org/Function_Reference/plugin_basename | |
| 43 | - * @see http://php.net/manual/en/language.constants.predefined.php | |
| 42 | + * @see https://codex.wordpress.org/Function_Reference/plugin_basename | |
| 43 | + * @see http://php.net/manual/en/language.constants.predefined.php | |
| 44 | 44 | */ |
| 45 | 45 | define( 'WOO_ADDITIONAL_TERMS_VERSION', '1.2.0' ); |
| 46 | 46 | define( 'WOO_ADDITIONAL_TERMS_FILE', __FILE__ ); |
| 47 | -define( 'WOO_ADDITIONAL_TERMS_NAME', get_file_data( WOO_ADDITIONAL_TERMS_FILE, array( 'name' => 'Plugin Name' ) )['name'] ); | |
| 48 | 47 | define( 'WOO_ADDITIONAL_TERMS_BASENAME', basename( WOO_ADDITIONAL_TERMS_FILE ) ); |
| 49 | 48 | define( 'WOO_ADDITIONAL_TERMS_PLUGIN_BASENAME', plugin_basename( WOO_ADDITIONAL_TERMS_FILE ) ); |
| 50 | 49 | define( 'WOO_ADDITIONAL_TERMS_DIR_URL', plugin_dir_url( WOO_ADDITIONAL_TERMS_FILE ) ); |
| 51 | -define( 'WOO_ADDITIONAL_TERMS_DIR_PATH', plugin_dir_path( WOO_ADDITIONAL_TERMS_FILE ) ); | |
| 50 | +define( 'WOO_ADDITIONAL_TERMS_DIR_PATH', plugin_dir_path( WOO_ADDITIONAL_TERMS_FILE ) ); | |
| 52 | 51 | |
| 53 | 52 | if ( ! class_exists( 'Woo_Additional_Terms' ) ) : |
| 54 | 53 | |
| 55 | 54 | /** |
| @@ -57,27 +56,28 @@ | ||
| 57 | 56 | */ |
| 58 | 57 | final class Woo_Additional_Terms { |
| 59 | 58 | |
| 60 | 59 | /** |
| 61 | - * Instance of the class. | |
| 62 | - * | |
| 63 | - * @var object $instance | |
| 64 | - */ | |
| 65 | - private static $instance = null; | |
| 60 | + * Instance of the class. | |
| 61 | + * | |
| 62 | + * @var object $_instance | |
| 63 | + */ | |
| 64 | + private static $_instance = NULL; | |
| 66 | 65 | |
| 67 | 66 | /** |
| 68 | 67 | * Main `Woo_Additional_Terms` instance |
| 69 | 68 | * Ensures only one instance of `Woo_Additional_Terms` is loaded or can be loaded. |
| 70 | 69 | * |
| 70 | + * @access public | |
| 71 | 71 | * @return instance |
| 72 | 72 | */ |
| 73 | 73 | public static function instance() { |
| 74 | 74 | |
| 75 | - if ( is_null( self::$instance ) ) { | |
| 76 | - self::$instance = new self(); | |
| 75 | + if ( is_null( self::$_instance ) ) { | |
| 76 | + self::$_instance = new self(); | |
| 77 | 77 | } // End If Statement |
| 78 | 78 | |
| 79 | - return self::$instance; | |
| 79 | + return self::$_instance; | |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| @@ -82,21 +82,22 @@ | ||
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Setup class. |
| 85 | 85 | * |
| 86 | + * @access protected | |
| 86 | 87 | * @return void |
| 87 | 88 | */ |
| 88 | 89 | protected function __construct() { |
| 89 | 90 | |
| 90 | - add_action( 'plugins_loaded', array( $this, 'maybe_migrate_data' ), 10 ); | |
| 91 | - add_action( 'init', array( $this, 'textdomain' ), 10 ); | |
| 92 | - add_action( 'admin_notices', array( $this, 'activation' ), 10 ); | |
| 93 | - add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ), 999, 1 ); | |
| 94 | - add_action( 'woocommerce_settings_tabs_woo-additional-terms', array( $this, 'render_plugin_page' ), 10 ); | |
| 95 | - add_action( 'woocommerce_update_options_woo-additional-terms', array( $this, 'update_plugin_page' ), 10 ); | |
| 96 | - add_action( 'woocommerce_checkout_after_terms_and_conditions', array( $this, 'print_checkbox' ), 10 ); | |
| 97 | - add_action( 'woocommerce_checkout_process', array( $this, 'checkbox_error' ), 99 ); | |
| 98 | - add_filter( sprintf( 'plugin_action_links_%s', WOO_ADDITIONAL_TERMS_PLUGIN_BASENAME ), array( $this, 'action_links' ), 10, 1 ); | |
| 91 | + add_action( 'plugins_loaded', array( $this, 'maybe_migrate_data' ), 10 ); | |
| 92 | + add_action( 'init', array( $this, 'textdomain' ), 10 ); | |
| 93 | + add_action( 'admin_notices', array( $this, 'activation' ), 10 ); | |
| 94 | + add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_tab' ), 999, 1 ); | |
| 95 | + add_action( 'woocommerce_settings_tabs_woo-additional-terms', array( $this, 'render_plugin_page' ), 10 ); | |
| 96 | + add_action( 'woocommerce_update_options_woo-additional-terms', array( $this, 'update_plugin_page' ), 10 ); | |
| 97 | + add_action( 'woocommerce_checkout_after_terms_and_conditions', array( $this, 'print_checkbox' ), 10 ); | |
| 98 | + add_action( 'woocommerce_checkout_process', array( $this, 'checkbox_error' ), 99 ); | |
| 99 | + add_filter( sprintf( 'plugin_action_links_%s', WOO_ADDITIONAL_TERMS_PLUGIN_BASENAME ), array( $this, 'additional_links' ), 10, 1 ); | |
| 99 | 100 | |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | /** |
| @@ -101,13 +102,14 @@ | ||
| 101 | 102 | |
| 102 | 103 | /** |
| 103 | 104 | * Cloning instances of this class is forbidden. |
| 104 | 105 | * |
| 106 | + * @access protected | |
| 105 | 107 | * @return void |
| 106 | 108 | */ |
| 107 | 109 | protected function __clone() { |
| 108 | 110 | |
| 109 | - _doing_it_wrong( __FUNCTION__, esc_html_x( 'Cloning instances of this class is forbidden.', 'clone', 'woo-additional-terms' ), esc_html( WOO_ADDITIONAL_TERMS_VERSION ) ); | |
| 111 | + _doing_it_wrong( __FUNCTION__, _x( 'Cloning instances of this class is forbidden.', 'clone', 'woo-additional-terms' ) , WOO_ADDITIONAL_TERMS_VERSION ); | |
| 110 | 112 | |
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
| @@ -112,13 +114,14 @@ | ||
| 112 | 114 | |
| 113 | 115 | /** |
| 114 | 116 | * Unserializing instances of this class is forbidden. |
| 115 | 117 | * |
| 118 | + * @access public | |
| 116 | 119 | * @return void |
| 117 | 120 | */ |
| 118 | 121 | public function __wakeup() { |
| 119 | 122 | |
| 120 | - _doing_it_wrong( __FUNCTION__, esc_html_x( 'Unserializing instances of this class is forbidden.', 'wakeup', 'woo-additional-terms' ), esc_html( WOO_ADDITIONAL_TERMS_VERSION ) ); | |
| 123 | + _doing_it_wrong( __FUNCTION__, _x( 'Unserializing instances of this class is forbidden.', 'wakeup', 'woo-additional-terms' ) , WOO_ADDITIONAL_TERMS_VERSION ); | |
| 121 | 124 | |
| 122 | 125 | } |
| 123 | 126 | |
| 124 | 127 | /** |
| @@ -123,15 +126,16 @@ | ||
| 123 | 126 | |
| 124 | 127 | /** |
| 125 | 128 | * Migrate data from versions prior to 1.1.0. |
| 126 | 129 | * |
| 130 | + * @access public | |
| 127 | 131 | * @return void |
| 128 | 132 | */ |
| 129 | 133 | public function maybe_migrate_data() { |
| 130 | 134 | |
| 131 | 135 | $get_page_id = (int) get_option( 'wc_settings_tab_wat_section_page_id' ); |
| 132 | - $get_notice = (string) get_option( 'wc_settings_tab_wat_section_notice' ); | |
| 133 | - $get_error = (string) get_option( 'wc_settings_tab_wat_section_notice_error' ); | |
| 136 | + $get_notice = (string) get_option( 'wc_settings_tab_wat_section_notice' ); | |
| 137 | + $get_error = (string) get_option( 'wc_settings_tab_wat_section_notice_error' ); | |
| 134 | 138 | |
| 135 | 139 | if ( isset( $get_page_id ) && ! empty( $get_page_id ) ) { |
| 136 | 140 | delete_option( 'wc_settings_tab_wat_section_page_id' ); |
| 137 | 141 | update_option( '_woo_additional_terms_page_id', intval( $get_page_id ) ); |
| @@ -152,13 +156,14 @@ | ||
| 152 | 156 | /** |
| 153 | 157 | * Load languages file and text domains. |
| 154 | 158 | * Define the internationalization functionality. |
| 155 | 159 | * |
| 160 | + * @access public | |
| 156 | 161 | * @return void |
| 157 | 162 | */ |
| 158 | 163 | public function textdomain() { |
| 159 | 164 | |
| 160 | - load_plugin_textdomain( 'woo-additional-terms', false, dirname( dirname( WOO_ADDITIONAL_TERMS_PLUGIN_BASENAME ) ) . '/languages/' ); | |
| 165 | + load_plugin_textdomain( 'woo-additional-terms', FALSE, dirname( dirname( WOO_ADDITIONAL_TERMS_PLUGIN_BASENAME ) ) . '/languages/' ); | |
| 161 | 166 | |
| 162 | 167 | } |
| 163 | 168 | |
| 164 | 169 | /** |
| @@ -163,17 +168,16 @@ | ||
| 163 | 168 | |
| 164 | 169 | /** |
| 165 | 170 | * Query WooCommerce activation. |
| 166 | 171 | * |
| 172 | + * @access public | |
| 167 | 173 | * @return void |
| 168 | 174 | */ |
| 169 | 175 | public function activation() { |
| 170 | 176 | |
| 171 | 177 | if ( ! $this->is_woocommerce() ) { |
| 172 | - /* translators: 1: Dashicon, Open anchor tag, 2: Close anchor tag. */ | |
| 173 | - $message = sprintf( esc_html_x( '%1$s requires the following plugin: %2$sWooCommerce%3$s', 'admin notice', 'woo-additional-terms' ), sprintf( '<i class="dashicons dashicons-admin-plugins" style="vertical-align:sub"></i> <strong>%s</strong>', WOO_ADDITIONAL_TERMS_NAME ), '<a href="https://wordpress.org/plugins/woocommerce" target="_blank" rel="noopener noreferrer nofollow"><em>', '</em></a>' ); | |
| 174 | - printf( '<div class="notice notice-error notice-alt"><p>%s</p></div>', wp_kses_post( $message ) ); | |
| 175 | - return; | |
| 178 | + $message = sprintf( esc_html_x( 'Woo Additional Terms plugin requires the following plugin:%sWooCommerce%s', 'admin notice', 'woo-additional-terms' ), '<a href="https://wordpress.org/plugins/woocommerce" target="_blank" rel="noopener noreferrer nofollow"><em>', '</em></a>' ); | |
| 179 | + printf( '<div class="notice notice-warning notice-alt"><p>%s</p></div>', $message ); | |
| 176 | 180 | } // End If Statement |
| 177 | 181 | |
| 178 | 182 | } |
| 179 | 183 | |
| @@ -180,16 +184,17 @@ | ||
| 180 | 184 | /** |
| 181 | 185 | * Create plugin options tab (page). |
| 182 | 186 | * Add a new settings tab to the WooCommerce settings tabs array. |
| 183 | 187 | * |
| 184 | - * @param array $settings_tabs Array of WooCommerce setting tabs & their labels. | |
| 185 | - * @return array | |
| 188 | + * @access public | |
| 189 | + * @param array $settings_tab Array of WooCommerce setting tabs & their labels. | |
| 190 | + * @return array $settings_tab Modified list of of WooCommerce setting tabs & their labels. | |
| 186 | 191 | */ |
| 187 | 192 | public function add_settings_tab( $settings_tabs ) { |
| 188 | 193 | |
| 189 | 194 | $settings_tabs['woo-additional-terms'] = _x( 'Additional Terms', 'tab title', 'woo-additional-terms' ); |
| 190 | 195 | |
| 191 | - return $settings_tabs; | |
| 196 | + return $settings_tabs; | |
| 192 | 197 | |
| 193 | 198 | } |
| 194 | 199 | |
| 195 | 200 | /** |
| @@ -195,8 +200,9 @@ | ||
| 195 | 200 | /** |
| 196 | 201 | * Render and display plugin options page. |
| 197 | 202 | * Uses the WooCommerce admin fields API to output settings. |
| 198 | 203 | * |
| 204 | + * @access public | |
| 199 | 205 | * @return void |
| 200 | 206 | */ |
| 201 | 207 | public function render_plugin_page() { |
| 202 | 208 | |
| @@ -207,8 +213,9 @@ | ||
| 207 | 213 | /** |
| 208 | 214 | * Render and display plugin options page. |
| 209 | 215 | * Uses the WooCommerce options API to save settings. |
| 210 | 216 | * |
| 217 | + * @access public | |
| 211 | 218 | * @return void |
| 212 | 219 | */ |
| 213 | 220 | public function update_plugin_page() { |
| 214 | 221 | |
| @@ -216,37 +223,36 @@ | ||
| 216 | 223 | |
| 217 | 224 | } |
| 218 | 225 | |
| 219 | 226 | /** |
| 220 | - * Display additional terms and condition checkbox on | |
| 227 | + * Display additional terms and condition checkbox on | |
| 221 | 228 | * the checkout page before the submit (place order) button. |
| 222 | 229 | * |
| 230 | + * @access public | |
| 223 | 231 | * @return void |
| 224 | 232 | */ |
| 225 | 233 | public function print_checkbox() { |
| 226 | 234 | |
| 227 | 235 | $get_page_id = (int) get_option( '_woo_additional_terms_page_id' ); |
| 228 | - $get_notice = (string) get_option( '_woo_additional_terms_notice' ); | |
| 236 | + $get_notice = (string) get_option( '_woo_additional_terms_notice' ); | |
| 229 | 237 | |
| 230 | - // Bail out, if the page ID is not defined yet! | |
| 231 | - if ( ! isset( $get_page_id ) || empty( $get_page_id ) ) { | |
| 232 | - return; | |
| 233 | - } // End If Statement | |
| 238 | + // Bail out, if the page ID is not defined yet! | |
| 239 | + if ( ! isset( $get_page_id ) || empty( $get_page_id ) ) { | |
| 240 | + return; | |
| 241 | + } // End If Statement | |
| 234 | 242 | |
| 235 | - if ( false !== strpos( $get_notice, '[additional-terms]' ) ) { | |
| 243 | + if ( FALSE !== strpos( $get_notice, '[additional-terms]' ) ) { | |
| 236 | 244 | $get_notice = str_replace( '[additional-terms]', sprintf( '<a href="%s" target="_blank" rel="noopener noreferrer nofollow">%s</a>', esc_url( get_permalink( $get_page_id ) ), esc_html( get_the_title( $get_page_id ) ) ), $get_notice ); // @codingStandardsIgnoreLine |
| 237 | 245 | } // End If Statement |
| 238 | 246 | |
| 239 | - woocommerce_form_field( | |
| 240 | - '_woo_additional_terms', array( | |
| 241 | - 'type' => 'checkbox', | |
| 242 | - 'class' => array( 'woo-additional-terms woocommerce-terms-and-conditions-wrapper' ), | |
| 243 | - 'label_class' => array( 'woocommerce-form__label woocommerce-form__label-for-checkbox checkbox' ), | |
| 244 | - 'input_class' => array( 'woocommerce-form__input woocommerce-form__input-checkbox input-checkbox' ), | |
| 245 | - 'required' => true, | |
| 246 | - 'label' => wp_kses_post( $get_notice ), | |
| 247 | - ) | |
| 248 | - ); | |
| 247 | + woocommerce_form_field( '_woo_additional_terms', array( | |
| 248 | + 'type' => 'checkbox', | |
| 249 | + 'class' => array( 'woo-additional-terms woocommerce-terms-and-conditions-wrapper' ), | |
| 250 | + 'label_class' => array( 'woocommerce-form__label woocommerce-form__label-for-checkbox checkbox' ), | |
| 251 | + 'input_class' => array( 'woocommerce-form__input woocommerce-form__input-checkbox input-checkbox' ), | |
| 252 | + 'required' => TRUE, | |
| 253 | + 'label' => wp_kses_post( $get_notice ) | |
| 254 | + ) ); | |
| 249 | 255 | |
| 250 | 256 | } |
| 251 | 257 | |
| 252 | 258 | /** |
| @@ -251,19 +257,19 @@ | ||
| 251 | 257 | |
| 252 | 258 | /** |
| 253 | 259 | * Show notice if customer does not accept additional terms and conditions. |
| 254 | 260 | * |
| 261 | + * @access public | |
| 255 | 262 | * @return void |
| 256 | 263 | */ |
| 257 | 264 | public function checkbox_error() { |
| 258 | 265 | |
| 259 | 266 | $get_page_id = (int) get_option( '_woo_additional_terms_page_id' ); |
| 260 | - $get_error = (string) get_option( '_woo_additional_terms_error' ); | |
| 267 | + $get_error = (string) get_option( '_woo_additional_terms_error' ); | |
| 261 | 268 | |
| 262 | - // phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification | |
| 263 | - if ( ! (int) isset( $_POST['_woo_additional_terms'], $get_page_id ) && ! empty( $get_page_id ) ) { | |
| 264 | - wc_add_notice( wp_kses_post( $get_error ), 'error' ); | |
| 265 | - } // End If Statement | |
| 269 | + if ( ! (int) isset( $_POST['_woo_additional_terms'], $get_page_id ) && ! empty( $get_page_id ) ) { | |
| 270 | + wc_add_notice( wp_kses_post( $get_error ), 'error' ); | |
| 271 | + } // End If Statement | |
| 266 | 272 | |
| 267 | 273 | } |
| 268 | 274 | |
| 269 | 275 | /** |
| @@ -268,63 +274,63 @@ | ||
| 268 | 274 | |
| 269 | 275 | /** |
| 270 | 276 | * Get all the settings for this plugin. |
| 271 | 277 | * |
| 272 | - * @return array | |
| 278 | + * @access public | |
| 279 | + * @return void | |
| 273 | 280 | */ |
| 274 | 281 | public static function get_settings() { |
| 275 | 282 | |
| 276 | 283 | $settings = array( |
| 277 | - 'upsell_title' => array( | |
| 284 | + 'upsell_title' => array( | |
| 278 | 285 | 'name' => _x( 'Looking for help customizing this plugin?', 'upsell', 'woo-additional-terms' ), |
| 279 | 286 | 'type' => 'title', |
| 280 | - /* translators: 1: Open anchor tag, 2: Close anchor tag. */ | |
| 281 | - 'desc' => sprintf( _x( '%1$sHire me →%2$s', 'upsell', 'woo-additional-terms' ), '<a href="https://www.upwork.com/o/profiles/users/_~016ad17ad3fc5cce94/" class="button-secondary" target="_blank" rel="noopener noreferrer nofollow">', '</a>' ), | |
| 287 | + 'desc' => sprintf( _x( '%sHire me →%s', 'upsell', 'woo-additional-terms' ), '<a href="https://www.upwork.com/o/profiles/users/_~016ad17ad3fc5cce94/" class="button-secondary" target="_blank" rel="noopener noreferrer nofollow">', '</a>' ) | |
| 282 | 288 | ), |
| 283 | 289 | 'section_end_upsell' => array( |
| 284 | - 'type' => 'sectionend', | |
| 290 | + 'type' => 'sectionend' | |
| 285 | 291 | ), |
| 286 | - 'section_title' => array( | |
| 292 | + 'section_title' => array( | |
| 287 | 293 | 'name' => _x( 'Terms and Conditions', 'settings section name', 'woo-additional-terms' ), |
| 288 | 294 | 'type' => 'title', |
| 289 | - 'desc' => _x( 'This section controls the display of your additional terms and condition fieldset.', 'settings section description', 'woo-additional-terms' ), | |
| 295 | + 'desc' => _x( 'This section controls the display of your additional terms and condition fieldset.', 'settings section description', 'woo-additional-terms' ) | |
| 290 | 296 | ), |
| 291 | - 'page_id' => array( | |
| 292 | - 'name' => _x( 'Terms page', 'settings field name', 'woo-additional-terms' ), | |
| 293 | - 'desc' => _x( 'If you define a "Terms" page the customer will be asked if they accept additional terms when checking out.', 'settings field description', 'woo-additional-terms' ), | |
| 294 | - 'type' => 'single_select_page', | |
| 295 | - 'class' => 'wc-enhanced-select-nostd', | |
| 296 | - 'css' => 'min-width:300px;', | |
| 297 | - 'id' => '_woo_additional_terms_page_id', | |
| 298 | - 'desc_tip' => true, | |
| 299 | - 'autoload' => false, | |
| 297 | + 'page_id' => array( | |
| 298 | + 'name' => _x( 'Terms page', 'settings field name', 'woo-additional-terms' ), | |
| 299 | + 'desc' => _x( 'If you define a "Terms" page the customer will be asked if they accept additional terms when checking out.', 'settings field description', 'woo-additional-terms' ), | |
| 300 | + 'type' => 'single_select_page', | |
| 301 | + 'class' => 'wc-enhanced-select-nostd', | |
| 302 | + 'css' => 'min-width:300px;', | |
| 303 | + 'id' => '_woo_additional_terms_page_id', | |
| 304 | + 'desc_tip' => TRUE, | |
| 305 | + 'autoload' => FALSE | |
| 300 | 306 | ), |
| 301 | - 'notice' => array( | |
| 302 | - 'name' => _x( 'Notice content', 'settings field name', 'woo-additional-terms' ), | |
| 303 | - 'desc' => _x( 'Text for the additional terms checkbox that customers must accept.', 'settings field description', 'woo-additional-terms' ), | |
| 304 | - 'default' => _x( 'I have read and agree to the website [additional-terms]', 'settings field default value', 'woo-additional-terms' ), | |
| 305 | - 'type' => 'textarea', | |
| 306 | - 'css' => 'min-width:300px;', | |
| 307 | - 'id' => '_woo_additional_terms_notice', | |
| 308 | - 'desc_tip' => true, | |
| 309 | - 'autoload' => false, | |
| 307 | + 'notice' => array( | |
| 308 | + 'name' => _x( 'Notice content', 'settings field name', 'woo-additional-terms' ), | |
| 309 | + 'desc' => _x( 'Text for the additional terms checkbox that customers must accept.', 'settings field description', 'woo-additional-terms' ), | |
| 310 | + 'default' => _x( 'I have read and agree to the website [additional-terms]', 'settings field default value', 'woo-additional-terms' ), | |
| 311 | + 'type' => 'textarea', | |
| 312 | + 'css' => 'min-width:300px;', | |
| 313 | + 'id' => '_woo_additional_terms_notice', | |
| 314 | + 'desc_tip' => TRUE, | |
| 315 | + 'autoload' => FALSE | |
| 310 | 316 | ), |
| 311 | - 'error' => array( | |
| 312 | - 'name' => _x( 'Error content', 'settings field name', 'woo-additional-terms' ), | |
| 313 | - 'desc' => _x( 'Display friendly notice whenever customer doesn’t accept additional terms.', 'settings field description', 'woo-additional-terms' ), | |
| 314 | - 'default' => _x( 'Please read and accept the additional terms and conditions to proceed with your order. ', 'settings field default value', 'woo-additional-terms' ), | |
| 315 | - 'type' => 'text', | |
| 316 | - 'css' => 'min-width:300px;', | |
| 317 | - 'id' => '_woo_additional_terms_error', | |
| 318 | - 'desc_tip' => true, | |
| 319 | - 'autoload' => false, | |
| 317 | + 'error' => array( | |
| 318 | + 'name' => _x( 'Error content', 'settings field name', 'woo-additional-terms' ), | |
| 319 | + 'desc' => _x( 'Display friendly notice whenever customer doesn’t accept additional terms.', 'settings field description', 'woo-additional-terms' ), | |
| 320 | + 'default' => _x( 'Please read and accept the additional terms and conditions to proceed with your order. ', 'settings field default value', 'woo-additional-terms' ), | |
| 321 | + 'type' => 'text', | |
| 322 | + 'css' => 'min-width:300px;', | |
| 323 | + 'id' => '_woo_additional_terms_error', | |
| 324 | + 'desc_tip' => TRUE, | |
| 325 | + 'autoload' => FALSE | |
| 320 | 326 | ), |
| 321 | - 'section_end' => array( | |
| 322 | - 'type' => 'sectionend', | |
| 323 | - ), | |
| 324 | - ); | |
| 327 | + 'section_end' => array( | |
| 328 | + 'type' => 'sectionend' | |
| 329 | + ) | |
| 330 | + ); | |
| 325 | 331 | |
| 326 | - return (array) apply_filters( 'woo_additional_terms_settings_args', $settings ); | |
| 332 | + return (array) apply_filters( 'woo_additional_terms_settings_args', $settings ); | |
| 327 | 333 | |
| 328 | 334 | } |
| 329 | 335 | |
| 330 | 336 | /** |
| @@ -330,28 +336,21 @@ | ||
| 330 | 336 | /** |
| 331 | 337 | * Display additional links in plugins table page. |
| 332 | 338 | * Filters the list of action links displayed for a specific plugin in the Plugins list table. |
| 333 | 339 | * |
| 334 | - * @param array $links Plugin table/item action links. | |
| 335 | - * @return array | |
| 340 | + * @access public | |
| 341 | + * @param array $links | |
| 342 | + * @return array $links | |
| 336 | 343 | */ |
| 337 | - public function action_links( $links ) { | |
| 344 | + public function additional_links( $links ) { | |
| 338 | 345 | |
| 339 | 346 | $plugin_links = array(); |
| 340 | - /* translators: 1: Open anchor tag, 2: Close anchor tag. */ | |
| 341 | - $plugin_links[] = sprintf( _x( '%1$sHire Me!%2$s', 'plugin link', 'woo-additional-terms' ), sprintf( '<a href="https://www.upwork.com/o/profiles/users/_~016ad17ad3fc5cce94/" class="button-link-delete" target="_blank" rel="noopener noreferrer nofollow" title="%s">', esc_attr_x( 'Looking for help? Hire Me!', 'upsell', 'woo-additional-terms' ) ), '</a>' ); | |
| 342 | - /* translators: 1: Open anchor tag, 2: Close anchor tag. */ | |
| 343 | - $plugin_links[] = sprintf( _x( '%1$sSupport%2$s', 'plugin link', 'woo-additional-terms' ), '<a href="https://wordpress.org/support/plugin/woo-additional-terms" target="_blank" rel="noopener noreferrer nofollow">', '</a>' ); | |
| 347 | + $plugin_links[] = sprintf( _x( '%sHire Me!%s', 'plugin link', 'woo-additional-terms' ) , sprintf( '<a href="https://www.upwork.com/o/profiles/users/_~016ad17ad3fc5cce94/" class="button-link-delete" target="_blank" rel="noopener noreferrer nofollow" title="%s">', esc_attr_x( 'Looking for help? Hire Me!', 'upsell', 'woo-additional-terms' ) ), '</a>' ); | |
| 348 | + $plugin_links[] = sprintf( _x( '%sSupport%s', 'plugin link', 'woo-additional-terms' ) , '<a href="https://wordpress.org/support/plugin/woo-additional-terms" target="_blank" rel="noopener noreferrer nofollow">', '</a>' ); | |
| 344 | 349 | |
| 345 | 350 | if ( $this->is_woocommerce() ) { |
| 346 | - $settings_url = add_query_arg( | |
| 347 | - array( | |
| 348 | - 'page' => 'wc-settings', | |
| 349 | - 'tab' => 'woo-additional-terms', | |
| 350 | - ), admin_url( 'admin.php' ) | |
| 351 | - ); | |
| 352 | - /* translators: 1: Open anchor tag, 2: Close anchor tag. */ | |
| 353 | - $plugin_links[] = sprintf( _x( '%1$sSettings%2$s', 'plugin link', 'woo-additional-terms' ), sprintf( '<a href="%s" target="_self">', esc_url( $settings_url ) ), '</a>' ); | |
| 351 | + $settings_url = add_query_arg( array( 'page' => 'wc-settings', 'tab' => 'woo-additional-terms' ), admin_url( 'admin.php' ) ); | |
| 352 | + $plugin_links[] = sprintf( _x( '%sSettings%s', 'plugin link', 'woo-additional-terms') , sprintf( '<a href="%s" target="_self">', esc_url( $settings_url ) ), '</a>' ); | |
| 354 | 353 | } // End If Statement |
| 355 | 354 | |
| 356 | 355 | return array_merge( $plugin_links, $links ); |
| 357 | 356 | |
| @@ -359,17 +358,18 @@ | ||
| 359 | 358 | |
| 360 | 359 | /** |
| 361 | 360 | * Query WooCommerce activation |
| 362 | 361 | * |
| 363 | - * @return bool | |
| 362 | + * @access private | |
| 363 | + * @return void | |
| 364 | 364 | */ |
| 365 | 365 | private function is_woocommerce() { |
| 366 | 366 | |
| 367 | 367 | if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { |
| 368 | - return false; | |
| 368 | + return FALSE; | |
| 369 | 369 | } // End If Statement |
| 370 | 370 | |
| 371 | - return true; | |
| 371 | + return TRUE; | |
| 372 | 372 | |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | } |
| @@ -374,17 +374,19 @@ | ||
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | endif; |
| 377 | 377 | |
| 378 | +/** | |
| 379 | + * Returns the main instance of Woo_Additional_Terms to prevent the need to use globals. | |
| 380 | + * | |
| 381 | + * @return object(class) Woo_Additional_Terms::instance | |
| 382 | + */ | |
| 378 | 383 | if ( ! function_exists( 'woo_additional_terms_init' ) ) : |
| 384 | + | |
| 385 | + function woo_additional_terms_init() { | |
| 379 | 386 | |
| 380 | - /** | |
| 381 | - * Returns the main instance of Woo_Additional_Terms to prevent the need to use globals. | |
| 382 | - * | |
| 383 | - * @return object(class) Woo_Additional_Terms::instance | |
| 384 | - */ | |
| 385 | - function woo_additional_terms_init() { | |
| 386 | 387 | return Woo_Additional_Terms::instance(); |
| 388 | + | |
| 387 | 389 | } |
| 388 | 390 | |
| 389 | 391 | woo_additional_terms_init(); |
| 390 | -endif; | |
| 392 | +endif; | |