diff --git a/affiliates.php b/affiliates.php index ae3b941..a6b4248 100644 --- a/affiliates.php +++ b/affiliates.php @@ -21,7 +21,7 @@ * Plugin Name: Affiliates * Plugin URI: http://www.itthinx.com/plugins/affiliates * Description: The Affiliates plugin provides the right tools to maintain a partner referral program. - * Version: 4.5.0 + * Version: 4.6.0 * Author: itthinx * Author URI: http://www.itthinx.com * Donate-Link: http://www.itthinx.com @@ -35,7 +35,7 @@ } if ( !defined( 'AFFILIATES_CORE_VERSION' ) ) { - define( 'AFFILIATES_CORE_VERSION', '4.5.0' ); + define( 'AFFILIATES_CORE_VERSION', '4.6.0' ); define( 'AFFILIATES_PLUGIN_NAME', 'affiliates' ); define( 'AFFILIATES_FILE', __FILE__ ); define( 'AFFILIATES_PLUGIN_BASENAME', plugin_basename( AFFILIATES_FILE ) ); @@ -48,6 +48,9 @@ if ( !defined( 'AFFILIATES_CORE_URL' ) ) { define( 'AFFILIATES_CORE_URL', WP_PLUGIN_URL . '/affiliates' ); } + if ( !defined( 'AFFILIATES_WPML' ) ) { + define( 'AFFILIATES_WPML', true ); + } require_once AFFILIATES_CORE_LIB . '/constants.php'; require_once AFFILIATES_CORE_LIB . '/wp-init.php'; } diff --git a/changelog.txt b/changelog.txt index f21a52d..2086c75 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,12 @@ == Affiliates - Changelog == += 4.6.0 = +* WordPress 5.4 compatible. +* Fixed a notice related to the deprecated contextual_help action. +* Added the affiliates_admin_help_show_screen filter. +* Added support for registration field label translation with WPML, requires WPML >= 3.2 and WPML String Translation. +* Added the AFFILIATES_WPML constant that can be used to enable/disable support for translation with WPML (enabled by default). + = 4.5.0 = * WordPress 5.3 compatibility retested. * Updated referral process of user registration integration. diff --git a/css/affiliates_admin.css b/css/affiliates_admin.css index 6778161..5682ede 100644 --- a/css/affiliates_admin.css +++ b/css/affiliates_admin.css @@ -544,3 +544,7 @@ li.add-ons:hover { text-align: left; margin: 0 0.62em; } + +body.wp-admin div.campaigns div.buttons { + padding-top: 1em; +} diff --git a/lib/core/affiliates-admin-add-ons.php b/lib/core/affiliates-admin-add-ons.php index 69b15eb..c436728 100644 --- a/lib/core/affiliates-admin-add-ons.php +++ b/lib/core/affiliates-admin-add-ons.php @@ -38,6 +38,8 @@ function affiliates_admin_add_ons() { echo esc_html__( 'Get additional features and access to premium support!', 'affiliates' ); echo '

'; + affiliates_donate(); + echo '

'; printf( __( 'Please also refer to the available Integrations.', 'affiliates' ), diff --git a/lib/core/class-affiliates-admin-help.php b/lib/core/class-affiliates-admin-help.php new file mode 100644 index 0000000..ecfa6f6 --- /dev/null +++ b/lib/core/class-affiliates-admin-help.php @@ -0,0 +1,139 @@ +id; + + $pname = get_option( 'aff_pname', AFFILIATES_PNAME ); + + $show_affiliates_help = false; + + $title = '

'; + $title .= esc_html__( 'Affiliates', 'affiliates' ); + $title .= '

'; + + $help = apply_filters( 'affiliates_help_tab_title', $title ); + + switch ( $screen_id ) { + case 'toplevel_page_affiliates-admin' : + case 'affiliates_page_affiliates-admin-affiliates': + case 'affiliates_page_affiliates-admin-hits' : + case 'affiliates_page_affiliates-admin-hits-affiliate' : + case 'affiliates_page_affiliates-admin-totals' : + case 'affiliates_page_affiliates-admin-referrals' : + case 'affiliates_page_affiliates-admin-options' : + $show_affiliates_help = true; + break; + default: + $show_affiliates_help = + strpos( $screen_id, 'affiliates_page_affiliates' ) !== false || + apply_filters( 'affiliates_admin_help_show_screen', false, $screen_id ); + } + + $help .= self::affiliates_help_tab_footer( false ); + + if ( !defined( 'AFFILIATES_PRO_PLUGIN_DOMAIN' ) && !defined( 'AFFILIATES_ENTERPRISE_PLUGIN_DOMAIN' ) ) { + $help .= '

'; + $help .= esc_html__( 'We highly appreciate it if you support our work by using our commercial software.', 'affiliates' ); + $help .= '

'; + $help .= '

'; + $help .= affiliates_donate( false, true ); + $help .= '

'; + } + + if ( $show_affiliates_help ) { + $screen->add_help_tab( + array( + 'id' => 'affiliates', + 'title' => esc_html__( 'Affiliates', 'affiliates' ), + 'content' => $help + ) + ); + } + } + } + + /** + * Returns or renders the common footer for help tabs. + * + * @param boolean $render + * + * @return string or nothing + */ + public static function affiliates_help_tab_footer( $render = true ) { + + $prefix = '

'; + $prefix .= __( 'The complete documentation is available on the Documentation pages …', 'affiliates' ); + $prefix .= '

'; + + $footer = + '
' . + sprintf( + '%s', + esc_attr( 'http://docs.itthinx.com/document/affiliates/' ), + esc_html( __( 'Online documentation', 'affiliates' ) ) + ) . + '
'; + $footer = apply_filters( 'affiliates_help_tab_footer', $footer ); + + $footer = $prefix . $footer; + + if ( $render ) { + echo $footer; + } else { + return $footer; + } + } +} +Affiliates_Admin_Help::init(); diff --git a/lib/core/class-affiliates-registration.php b/lib/core/class-affiliates-registration.php index a1eaafd..faafbd6 100644 --- a/lib/core/class-affiliates-registration.php +++ b/lib/core/class-affiliates-registration.php @@ -92,6 +92,38 @@ public static function init() { // delete affiliate when user is deleted add_action( 'deleted_user', array( __CLASS__, 'deleted_user' ) ); + + add_action( 'init', array( __CLASS__, 'wp_init' ) ); + } + + /** + * Registers registration field labels with WPML. + * + * @link https://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/ + */ + public static function wp_init() { + if ( defined( 'AFFILIATES_WPML' ) && AFFILIATES_WPML ) { + require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings.php'; + require_once AFFILIATES_CORE_LIB . '/class-affiliates-settings-registration.php'; + $registration_fields = Affiliates_Settings_Registration::get_fields(); + if ( is_array( $registration_fields ) ) { + foreach( $registration_fields as $name => $field ) { + // context, name, value + do_action( 'wpml_register_single_string', 'affiliates', self::get_wpml_string_name( $name ), $field['label'] ); + } + } + } + } + + /** + * Returns the string's registered name for use with WPML string translation. + * + * @param string $name + * + * @return string registered name + */ + private static function get_wpml_string_name( $name ) { + return sprintf( 'Field Label: %s', esc_attr( $name ) ); } /** @@ -439,7 +471,15 @@ public static function render_fields( $registration_fields = null ) { if ( $field['enabled'] ) { $output .= '
'; $output .= '