Skip to content

Commit

Permalink
Merge pull request #104 from itthinx/tested-4.6.0-5.4
Browse files Browse the repository at this point in the history
Tested 4.6.0 5.4
  • Loading branch information
itthinx authored Apr 16, 2020
2 parents fac1bf5 + 6a3f97a commit cea742c
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 120 deletions.
7 changes: 5 additions & 2 deletions affiliates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ) );
Expand All @@ -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';
}
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 4 additions & 0 deletions css/affiliates_admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions lib/core/affiliates-admin-add-ons.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ function affiliates_admin_add_ons() {
echo esc_html__( 'Get additional features and access to premium support!', 'affiliates' );
echo '</p>';

affiliates_donate();

echo '<p>';
printf(
__( 'Please also refer to the available <a href="%s">Integrations</a>.', 'affiliates' ),
Expand Down
139 changes: 139 additions & 0 deletions lib/core/class-affiliates-admin-help.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php
/**
* class-affiliates-admin-help.php
*
* Copyright (c) "kento" Karim Rahimpur www.itthinx.com
*
* This code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This header and all notices must be kept intact.
*
* @author Karim Rahimpur
* @package affiliates
* @since 4.6.0
*/

if ( !defined( 'ABSPATH' ) ) {
exit;
}

/**
* Returns or renders the common footer for help tabs.
*
* @param boolean $render
*
* @return string
*/
function affiliates_help_tab_footer( $render = true ) {
return Affiliates_Admin_Help::affiliates_help_tab_footer( $render );
}

/**
* Help sections of the Affiliates system.
*/
class Affiliates_Admin_Help {

/**
* Adds the filter for contextual help.
*/
public static function init() {
add_action( 'current_screen', array( __CLASS__, 'current_screen' ) );
}

/**
* Adds contextual help on our screens.
*
* @param WP_Screen $screen
*/
public static function current_screen( $screen ) {
if ( $screen instanceof WP_Screen ) {
$screen_id = $screen->id;

$pname = get_option( 'aff_pname', AFFILIATES_PNAME );

$show_affiliates_help = false;

$title = '<h3>';
$title .= esc_html__( 'Affiliates', 'affiliates' );
$title .= '</h3>';

$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 .= '<p>';
$help .= esc_html__( 'We highly appreciate it if you support our work by using our commercial software.', 'affiliates' );
$help .= '</p>';
$help .= '<p>';
$help .= affiliates_donate( false, true );
$help .= '</p>';
}

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 = '<p>';
$prefix .= __( 'The complete documentation is available on the Documentation pages &hellip;', 'affiliates' );
$prefix .= '</p>';

$footer =
'<div class="affiliates-documentation">' .
sprintf(
'<a href="%s">%s</a>',
esc_attr( 'http://docs.itthinx.com/document/affiliates/' ),
esc_html( __( 'Online documentation', 'affiliates' ) )
) .
'</div>';
$footer = apply_filters( 'affiliates_help_tab_footer', $footer );

$footer = $prefix . $footer;

if ( $render ) {
echo $footer;
} else {
return $footer;
}
}
}
Affiliates_Admin_Help::init();
42 changes: 41 additions & 1 deletion lib/core/class-affiliates-registration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand Down Expand Up @@ -439,7 +471,15 @@ public static function render_fields( $registration_fields = null ) {
if ( $field['enabled'] ) {
$output .= '<div class="field">';
$output .= '<label>';
$output .= stripslashes( $field['label'] );
$label = $field['label'];
// Translate registration field labels with WPML String Translation?
// https://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/
// https://wpml.org/wpml-hook/wpml_translate_single_string/
if ( defined( 'AFFILIATES_WPML' ) && AFFILIATES_WPML ) {
// original value, domain, name, language code (optional and not used here)
$label = apply_filters( 'wpml_translate_single_string', $field['label'], 'affiliates', self::get_wpml_string_name( $name ) );
}
$output .= stripslashes( $label );
$output .= ' ';
$type = isset( $field['type'] ) ? $field['type'] : 'text';
$readonly = is_user_logged_in() && ( ( $name == 'user_login' ) || ( $name == 'user_email' ) ) ? ' readonly="readonly" ' : '';
Expand Down
116 changes: 1 addition & 115 deletions lib/core/wp-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -1945,121 +1945,7 @@ function affiliates_network_admin_menu() {
do_action( 'affiliates_network_admin_menu', $pages );
}

add_action( 'contextual_help', 'affiliates_contextual_help', 10, 3 );

function affiliates_contextual_help( $contextual_help, $screen_id, $screen ) {

$pname = get_option( 'aff_pname', AFFILIATES_PNAME );

$show_affiliates_help = false;

$title = '<h3>';
$title .= sprintf( '<a href="%s" target="_blank">%s</a>', esc_attr( 'http://www.itthinx.com/plugins/affiliates' ), __( 'Affiliates', 'affiliates' ) );
$title .= '</h3>';

$help = apply_filters( 'affiliates_help_tab_title', $title );

switch ( $screen_id ) {
case 'toplevel_page_affiliates-admin' :
$show_affiliates_help = true;
$help .= '<p>' . __( 'This screen offers an overview with basic statistical data.', 'affiliates' ) . '</p>';
$help .= '<ul>';
$help .= '<li>' . __( '<em>From operative affiliates:</em> includes affiliates that are currently active. This excludes affiliates whose dates are not currently valid as well as those that have been deleted.', 'affiliates' ) . '</li>';
$help .= '<li>' . __( '<em>From operative and non-operative affiliates:</em> excludes deleted affiliates.', 'affiliates' ) . '</li>';
$help .= '<li>' . __( '<em>All time</em> includes data from any affiliates, including deleted affiliates.', 'affiliates' ) . '</li>';
$help .= '<ul>';
$help .= '<ul>';
$help .= '<li>' . __( '<em>Hits</em> are HTTP requests for affiliate links.', 'affiliates' ) . '</li>';
$help .= '<li>' . __( '<em>Visits</em> are unique and daily requests for affiliate links.', 'affiliates' ) . '</li>';
$help .= '<li>' . __( '<em>Referrals</em> are recording commissions and referral data.', 'affiliates' ) . '</li>';
$help .= '</ul>';
$help .= '<p>';
$help .= __( 'The Affiliates plugin provides the <em>Affiliates Contact</em> widget that can be used to record lead referrals.', 'affiliates' );
$help .= sprintf( __( 'To use it, place the widget in one of your <a href="%s">widget areas</a>.', 'affiliates' ), get_admin_url( null, 'widgets.php' ) );
$help .= '</p>';

$help .= '<p>';
$help .= __( 'Note that <em>deleted</em> affiliates are not literally deleted but marked as such so that data that has been collected will still be accesible.', 'affiliates' );
$help .= '</p>';
break;
case 'affiliates_page_affiliates-admin-affiliates':
$show_affiliates_help = true;
$help .=
'<p>' .
__( 'Here you can <strong>add</strong>, <strong>edit</strong> and <strong>remove</strong> affiliates.', 'affiliates' ) .
'</p>';
$help .=
'<ul>' .
'<li>' .
'<p class="affiliate-link">' .
__( 'Affiliate link', 'affiliates' ) .
'<p/>' .
'<p>' .
__( 'This link uses a parameter in the URL to record visits you receive through your affiliates.', 'affiliates' ) . ' ' .
'<br/>' .
sprintf( __( 'You may also append the ?%s=... part to links to your posts.', 'affiliates' ), $pname ) .
'</p>' .
'</li>' .
'</ul>' .
'<p>' .
__( 'Once a visitor has landed on your site through an affiliate link, referrals may be recorded and attributed to the affiliate.', 'affiliates' ) .
'</p>';
break;
case 'affiliates_page_affiliates-admin-hits' :
$show_affiliates_help = true;
break;
case 'affiliates_page_affiliates-admin-hits-affiliate' :
$show_affiliates_help = true;
break;
case 'affiliates_page_affiliates-admin-totals' :
$show_affiliates_help = true;
break;
case 'affiliates_page_affiliates-admin-referrals' :
$show_affiliates_help = true;
break;
case 'affiliates_page_affiliates-admin-options' :
$show_affiliates_help = true;
break;
default:
$show_affiliates_help = strpos( $screen_id, 'affiliates_page_affiliates' ) !== false;
}

if ( !defined( 'AFFILIATES_PRO_PLUGIN_DOMAIN' ) && !defined( 'AFFILIATES_ENTERPRISE_PLUGIN_DOMAIN' ) ) {
$help .= '<p>';
$help .= affiliates_donate( false, true );
$help .= '</p>';
}

$help .= affiliates_help_tab_footer( false );

if ( $show_affiliates_help ) {
return $help;
} else {
return $contextual_help;
}
}

/**
* Returns or renders the common footer for help tabs.
* @param boolean $render
* @return string or nothing
*/
function affiliates_help_tab_footer( $render = true ) {
$footer =
'<div class="affiliates-documentation">' .
sprintf(
'<a href="%s">%s</a>',
esc_attr( 'http://docs.itthinx.com/document/affiliates/' ),
esc_html( __( 'Online documentation', 'affiliates' ) )
) .
'</div>';
$footer = apply_filters( 'affiliates_help_tab_footer', $footer );
if ( $render ) {
echo $footer;
} else {
return $footer;
}
}
require_once AFFILIATES_CORE_LIB . '/class-affiliates-admin-help.php';

/**
* Returns or renders the footer.
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: itthinx, proaktion
Donate link: https://www.itthinx.com/shop/
Tags: affiliate, affiliates, affiliate marketing, referral, growth marketing, ads, AddToAny, AddThis, advertising, affiliate plugin, affiliate tool, contact form, contact form 7, downloads, e-commerce, Ecwid, Events Manager, Jigoshop, lead, link, marketing, money, partner, Pay per Click, PayPal, PPC, referral links, referrer, sales, shopping cart, track, transaction, WooCommerce
Requires at least: 4.6.0
Tested up to: 5.3
Tested up to: 5.4
Requires PHP: 5.6.0
Stable tag: 4.5.0
Stable tag: 4.6.0
License: GPLv3

The Affiliates system provides the most powerful growth-oriented tools to run a successful Affiliate Marketing Program.
Expand Down

0 comments on commit cea742c

Please sign in to comment.