diff --git a/classes/admin.php b/classes/admin.php
index cebaf2c3..8583732a 100755
--- a/classes/admin.php
+++ b/classes/admin.php
@@ -496,12 +496,14 @@ public function show_admin_page() {
break;
} // End switch().
} catch ( SalesforceApiException $ex ) {
- echo sprintf( '
Error %1$s : %2$s
',
+ echo sprintf(
+ 'Error %1$s : %2$s
',
absint( $ex->getCode() ),
esc_html( $ex->getMessage() )
);
} catch ( Exception $ex ) {
- echo sprintf( 'Error %1$s : %2$s
',
+ echo sprintf(
+ 'Error %1$s : %2$s
',
absint( $ex->getCode() ),
esc_html( $ex->getMessage() )
);
@@ -581,8 +583,9 @@ private function fields_settings( $page, $section, $callbacks ) {
'args' => array(
'type' => 'url',
'validate' => 'sanitize_validate_text',
- // translators: %1$s is the admin URL for the Authorize tab
- 'desc' => sprintf( __( 'In most cases, you will want to use %1$s for this value.', 'object-sync-for-salesforce' ),
+ 'desc' => sprintf(
+ // translators: %1$s is the admin URL for the Authorize tab
+ __( 'In most cases, you will want to use %1$s for this value.', 'object-sync-for-salesforce' ),
get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize' )
),
'constant' => 'OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL',
@@ -596,8 +599,9 @@ private function fields_settings( $page, $section, $callbacks ) {
'args' => array(
'type' => 'url',
'validate' => 'sanitize_validate_text',
- // translators: 1) production salesforce login, 2) sandbox salesforce login
- 'desc' => sprintf( __( 'For most Salesforce setups, you should use %1$s for production and %2$s for sandbox. If you try to use an instance name as the URL, you may encounter Salesforce errors.', 'object-sync-for-salesforce' ),
+ 'desc' => sprintf(
+ // translators: 1) production salesforce login, 2) sandbox salesforce login
+ __( 'For most Salesforce setups, you should use %1$s for production and %2$s for sandbox. If you try to use an instance name as the URL, you may encounter Salesforce errors.', 'object-sync-for-salesforce' ),
esc_url( 'https://login.salesforce.com' ),
esc_url( 'https://test.salesforce.com' )
),
@@ -1805,7 +1809,8 @@ public function display_input_field( $args ) {
$value = $args['default'];
}
- echo sprintf( ' ',
+ echo sprintf(
+ ' ',
esc_attr( $type ),
esc_attr( $value ),
esc_attr( $name ),
@@ -1814,12 +1819,14 @@ public function display_input_field( $args ) {
esc_html( $checked )
);
if ( '' !== $desc ) {
- echo sprintf( '%1$s
',
+ echo sprintf(
+ '%1$s
',
esc_html( $desc )
);
}
} else {
- echo sprintf( '%1$s
',
+ echo sprintf(
+ '%1$s
',
esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
);
}
@@ -1847,7 +1854,8 @@ public function display_checkboxes( $args ) {
$checked = 'checked';
}
}
- echo sprintf( ' %6$s
',
+ echo sprintf(
+ ' %6$s
',
esc_attr( $type ),
esc_attr( $key ),
esc_attr( $name ),
@@ -1856,7 +1864,8 @@ public function display_checkboxes( $args ) {
esc_html( $text )
);
if ( '' !== $desc ) {
- echo sprintf( '%1$s
',
+ echo sprintf(
+ '%1$s
',
esc_html( $desc )
);
}
@@ -1876,7 +1885,8 @@ public function display_select( $args ) {
if ( ! isset( $args['constant'] ) || ! defined( $args['constant'] ) ) {
$current_value = get_option( $name );
- echo sprintf( '- ' . __( 'Select one', 'object-sync-for-salesforce' ) . ' - ',
+ echo sprintf(
+ '- ' . __( 'Select one', 'object-sync-for-salesforce' ) . ' - ',
esc_attr( $id ),
esc_attr( $name )
);
@@ -1889,7 +1899,8 @@ public function display_select( $args ) {
$selected = ' selected';
}
- echo sprintf( '%3$s ',
+ echo sprintf(
+ '%3$s ',
esc_attr( $value ),
esc_attr( $selected ),
esc_html( $text )
@@ -1898,13 +1909,15 @@ public function display_select( $args ) {
}
echo '';
if ( '' !== $desc ) {
- echo sprintf( '
%1$s
',
+ echo sprintf(
+ '
%1$s
',
esc_html( $desc )
);
}
echo '
';
} else {
- echo sprintf( '%1$s
',
+ echo sprintf(
+ '%1$s
',
esc_html__( 'Defined in wp-config.php', 'object-sync-for-salesforce' )
);
}
@@ -1940,20 +1953,23 @@ public function display_link( $args ) {
$desc = $args['desc'];
$url = $args['url'];
if ( isset( $args['link_class'] ) ) {
- echo sprintf( '%3$s
',
+ echo sprintf(
+ '%3$s
',
esc_attr( $args['link_class'] ),
esc_url( $url ),
esc_html( $label )
);
} else {
- echo sprintf( '%2$s
',
+ echo sprintf(
+ '%2$s
',
esc_url( $url ),
esc_html( $label )
);
}
if ( '' !== $desc ) {
- echo sprintf( '%1$s
',
+ echo sprintf(
+ '%1$s
',
esc_html( $desc )
);
}
@@ -2000,8 +2016,9 @@ private function status( $sfapi ) {
$versions_from_cache = esc_html__( 'items were not loaded from the cache', 'object-sync-salesforce' );
}
- // translators: 1) $versions_is_cached is the "This list is/is not cached, and/but" line, 2) $versions_from_cache is the "items were/were not loaded from the cache" line
- $versions_apicall_summary = sprintf( esc_html__( 'Available Salesforce API versions. %1$s %2$s. This is not an authenticated request, so it does not touch the Salesforce token.', 'object-sync-for-salesforce' ),
+ $versions_apicall_summary = sprintf(
+ // translators: 1) $versions_is_cached is the "This list is/is not cached, and/but" line, 2) $versions_from_cache is the "items were/were not loaded from the cache" line
+ esc_html__( 'Available Salesforce API versions. %1$s %2$s. This is not an authenticated request, so it does not touch the Salesforce token.', 'object-sync-for-salesforce' ),
$versions_is_cached,
$versions_from_cache
);
@@ -2055,7 +2072,8 @@ private function logout() {
$this->access_token = delete_option( $this->option_prefix . 'access_token' );
$this->instance_url = delete_option( $this->option_prefix . 'instance_url' );
$this->refresh_token = delete_option( $this->option_prefix . 'refresh_token' );
- echo sprintf( 'You have been logged out. You can use the %2$s tab to log in again.
',
+ echo sprintf(
+ 'You have been logged out. You can use the %2$s tab to log in again.
',
esc_url( get_admin_url( null, 'options-general.php?page=object-sync-salesforce-admin&tab=authorize' ) ),
esc_html__( 'Authorize', 'object-sync-for-salesforce' )
);
@@ -2201,8 +2219,17 @@ private function tabs( $tabs, $tab = '' ) {
echo '';
foreach ( $tabs as $tab_key => $tab_caption ) {
$active = $current_tab === $tab_key ? ' nav-tab-active' : '';
- if ( 'settings' === $tab_key || ( isset( $consumer_key ) && isset( $consumer_secret ) && ! empty( $consumer_key ) && ! empty( $consumer_secret ) ) ) {
- echo sprintf( '%3$s ',
+
+ if ( true === $this->salesforce['is_authorized'] ) {
+ echo sprintf(
+ '%3$s ',
+ esc_attr( $active ),
+ esc_url( '?page=object-sync-salesforce-admin&tab=' . $tab_key ),
+ esc_html( $tab_caption )
+ );
+ } elseif ( 'settings' === $tab_key || ( 'authorize' === $tab_key && isset( $consumer_key ) && isset( $consumer_secret ) && ! empty( $consumer_key ) && ! empty( $consumer_secret ) ) ) {
+ echo sprintf(
+ '%3$s ',
esc_attr( $active ),
esc_url( '?page=object-sync-salesforce-admin&tab=' . $tab_key ),
esc_html( $tab_caption )
@@ -2240,20 +2267,24 @@ private function clear_schedule( $schedule_name = '' ) {
*/
private function get_schedule_count( $schedule_name = '' ) {
if ( '' !== $schedule_name ) {
- $count = count( $this->queue->search(
- array(
- 'group' => $schedule_name,
- 'status' => ActionScheduler_Store::STATUS_PENDING,
- ),
- 'ARRAY_A'
- ) );
- $group_count = count( $this->queue->search(
- array(
- 'group' => $schedule_name . $this->action_group_suffix,
- 'status' => ActionScheduler_Store::STATUS_PENDING,
- ),
- 'ARRAY_A'
- ) );
+ $count = count(
+ $this->queue->search(
+ array(
+ 'group' => $schedule_name,
+ 'status' => ActionScheduler_Store::STATUS_PENDING,
+ ),
+ 'ARRAY_A'
+ )
+ );
+ $group_count = count(
+ $this->queue->search(
+ array(
+ 'group' => $schedule_name . $this->action_group_suffix,
+ 'status' => ActionScheduler_Store::STATUS_PENDING,
+ ),
+ 'ARRAY_A'
+ )
+ );
return $count + $group_count;
} else {
return 0;