Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Updated internal dependencies
  • Loading branch information
vytisbulkevicius authored May 20, 2024
2 parents dbc81e7 + 59ced27 commit b03d835
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 135 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 28 additions & 25 deletions includes/admin/class-rop-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ public function enqueue_scripts() {
wp_register_script( $this->plugin_name . '-dashboard', ROP_LITE_URL . 'assets/js/build/dashboard.js', array(), ( ROP_DEBUG ) ? time() : $this->version, false );
wp_register_script( $this->plugin_name . '-exclude', ROP_LITE_URL . 'assets/js/build/exclude.js', array(), ( ROP_DEBUG ) ? time() : $this->version, false );

$array_nonce = array(
$rop_api_settings = array(
'root' => esc_url_raw( rest_url( '/tweet-old-post/v8/api/' ) ),
);
if ( current_user_can( 'manage_options' ) ) {
$array_nonce = array(
$rop_api_settings = array(
'root' => esc_url_raw( rest_url( '/tweet-old-post/v8/api/' ) ),
'nonce' => wp_create_nonce( 'wp_rest' ),
);
Expand Down Expand Up @@ -336,32 +336,32 @@ public function enqueue_scripts() {
$global_settings = new Rop_Global_Settings();
$settings = new Rop_Settings_Model();

$array_nonce['license_type'] = $global_settings->license_type();
$array_nonce['fb_domain_toast_display'] = $this->facebook_exception_toast_display();
$array_nonce['labels'] = Rop_I18n::get_labels();
$array_nonce['upsell_link'] = Rop_I18n::UPSELL_LINK;
$array_nonce['pro_installed'] = ( defined( 'ROP_PRO_VERSION' ) ) ? true : false;
$array_nonce['staging'] = $this->rop_site_is_staging();
$array_nonce['show_li_app_btn'] = $li_service->rop_show_li_app_btn();
$array_nonce['show_tmblr_app_btn'] = $tmblr_service->rop_show_tmblr_app_btn();
$array_nonce['rop_get_wpml_active_status'] = $this->rop_get_wpml_active_status();
$array_nonce['rop_get_yoast_seo_active_status'] = $this->rop_get_yoast_seo_active_status();
$array_nonce['rop_is_edit_post_screen'] = $this->rop_is_edit_post_screen();
$array_nonce['rop_get_wpml_languages'] = $this->rop_get_wpml_languages();
$array_nonce['hide_own_app_option'] = $this->rop_hide_add_own_app_option();
$array_nonce['debug'] = ( ( ROP_DEBUG ) ? 'yes' : 'no' );
$array_nonce['tax_apply_limit'] = $this->limit_tax_dropdown_list();
$array_nonce['remote_cron_type_limit'] = $this->limit_remote_cron_system();
$array_nonce['exclude_apply_limit'] = $this->limit_exclude_list();
$array_nonce['publish_now'] = array(
$rop_api_settings['license_type'] = $global_settings->license_type();
$rop_api_settings['fb_domain_toast_display'] = $this->facebook_exception_toast_display();
$rop_api_settings['labels'] = Rop_I18n::get_labels();
$rop_api_settings['upsell_link'] = Rop_I18n::UPSELL_LINK;
$rop_api_settings['pro_installed'] = ( defined( 'ROP_PRO_VERSION' ) ) ? true : false;
$rop_api_settings['show_li_app_btn'] = $li_service->rop_show_li_app_btn();
$rop_api_settings['show_tmblr_app_btn'] = $tmblr_service->rop_show_tmblr_app_btn();
$rop_api_settings['staging'] = $this->rop_site_is_staging();
$rop_api_settings['rop_get_wpml_active_status'] = $this->rop_get_wpml_active_status();
$rop_api_settings['rop_get_yoast_seo_active_status'] = $this->rop_get_yoast_seo_active_status();
$rop_api_settings['rop_is_edit_post_screen'] = $this->rop_is_edit_post_screen();
$rop_api_settings['rop_get_wpml_languages'] = $this->rop_get_wpml_languages();
$rop_api_settings['hide_own_app_option'] = $this->rop_hide_add_own_app_option();
$rop_api_settings['debug'] = ( ( ROP_DEBUG ) ? 'yes' : 'no' );
$rop_api_settings['tax_apply_limit'] = $this->limit_tax_dropdown_list();
$rop_api_settings['remote_cron_type_limit'] = $this->limit_remote_cron_system();
$rop_api_settings['exclude_apply_limit'] = $this->limit_exclude_list();
$rop_api_settings['publish_now'] = array(
'instant_share_enabled' => $settings->get_instant_sharing(),
'instant_share_by_default' => $settings->get_instant_sharing_by_default(),
'choose_accounts_manually' => $settings->get_instant_share_choose_accounts_manually(),
'accounts' => $active_accounts,
);
$array_nonce['added_networks'] = $added_networks;
$array_nonce['rop_cron_remote'] = filter_var( get_option( 'rop_use_remote_cron', false ), FILTER_VALIDATE_BOOLEAN );
$array_nonce['rop_cron_remote_agreement'] = filter_var( get_option( 'rop_remote_cron_terms_agree', false ), FILTER_VALIDATE_BOOLEAN );
$rop_api_settings['added_networks'] = $added_networks;
$rop_api_settings['rop_cron_remote'] = filter_var( get_option( 'rop_use_remote_cron', false ), FILTER_VALIDATE_BOOLEAN );
$rop_api_settings['rop_cron_remote_agreement'] = filter_var( get_option( 'rop_remote_cron_terms_agree', false ), FILTER_VALIDATE_BOOLEAN );

$admin_url = get_admin_url( get_current_blog_id(), 'admin.php?page=TweetOldPost' );
$token = get_option( ROP_INSTALL_TOKEN_OPTION );
Expand All @@ -383,11 +383,14 @@ public function enqueue_scripts() {
);

if ( 'publish_now' === $page ) {
$array_nonce['publish_now'] = apply_filters( 'rop_publish_now_attributes', $array_nonce['publish_now'] );
$rop_api_settings['publish_now'] = apply_filters( 'rop_publish_now_attributes', $rop_api_settings['publish_now'] );
wp_register_script( $this->plugin_name . '-publish_now', ROP_LITE_URL . 'assets/js/build/publish_now.js', array(), ( ROP_DEBUG ) ? time() : $this->version, false );
}

wp_localize_script( $this->plugin_name . '-' . $page, 'ropApiSettings', $array_nonce );
$rop_api_settings['tracking'] = 'yes' === get_option( 'tweet_old_post_logger_flag', 'no' );
$rop_api_settings['tracking_info_link'] = sanitize_url( 'https://docs.revive.social/article/2008-revive-old-posts-usage-tracking' );

wp_localize_script( $this->plugin_name . '-' . $page, 'ropApiSettings', $rop_api_settings );
wp_localize_script( $this->plugin_name . '-' . $page, 'ROP_ASSETS_URL', array( ROP_LITE_URL . 'assets/' ) );
wp_localize_script( $this->plugin_name . '-' . $page, 'ropAuthAppData', $rop_auth_app_data );
wp_enqueue_script( $this->plugin_name . '-' . $page );
Expand Down
25 changes: 25 additions & 0 deletions includes/admin/class-rop-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1293,4 +1293,29 @@ private function add_account_vk( $data ) {
return $this->response->to_array();
}

/**
* API method called to toggle tracking.
*
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) As it is called dynamically.
*
* @param array $data The data from request.
* @return array The response.
*/
private function toggle_tracking( $data ) {
if ( ! isset( $data['tracking'] ) ) {
$this->response->set_code( '400' )
->set_message( 'Tracking data not found' )
->set_data( array() );

return $this->response->to_array();
}

$tracking = filter_var( $data['tracking'], FILTER_VALIDATE_BOOLEAN );
update_option( 'tweet_old_post_logger_flag', $tracking ? 'yes' : 'no' );

return $this->response->set_code( '200' )
->set_message( 'OK' )
->set_data( array( 'tracking' => $tracking ) )
->to_array();
}
}
2 changes: 2 additions & 0 deletions includes/class-rop-i18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ public static function get_labels( $key = '' ) {
'to' => __( 'to', 'tweet-old-post' ),
'by' => __( 'by', 'tweet-old-post' ),
'review_it' => __( 'Leave a review', 'tweet-old-post' ),
'tracking' => __( 'Send anonymous data to help us understand how you use the plugin.', 'tweet-old-post' ),
'tracking_info' => __( 'What do we track?', 'tweet-old-post' ), 'global_settings_header' => __( 'Global Settings', 'tweet-old-post' ),
'in' => __( 'in', 'tweet-old-post' ),
'start' => __( 'Start', 'tweet-old-post' ),
'stop' => __( 'Stop', 'tweet-old-post' ),
Expand Down
2 changes: 2 additions & 0 deletions tweet-old-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ function() {
}
);

add_filter( 'themeisle_sdk_enable_telemetry', '__return_true' );

$plugin = new Rop();
$plugin->run();

Expand Down
2 changes: 2 additions & 0 deletions vue/src/models/rop_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export default new Vuex.Store({
*/
rop_cron_remote: ropApiSettings.rop_cron_remote,
dom_updated: false,
tracking: Boolean( ropApiSettings.tracking ),
},
mutations: {

Expand Down Expand Up @@ -249,6 +250,7 @@ export default new Vuex.Store({
case 'toggle_account':
case 'exclude_post':
case 'exclude_post_batch':
case 'toggle_tracking':

break
default:
Expand Down
51 changes: 44 additions & 7 deletions vue/src/vue-elements/accounts-selector-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,57 @@
return;
}
this.is_loading = true;
const savedSettings = {
service: this.active_accounts[this.selected_account].service,
account_id: this.selected_account,
data: this.active_data[this.selected_account]
};
this.$store.dispatch('fetchAJAXPromise', {
req: 'save_' + this.action,
data: {
service: this.active_accounts[this.selected_account].service,
account_id: this.selected_account,
data: this.active_data[this.selected_account]
}
}).then(response => {
data: savedSettings
}).then(() => {
this.is_loading = false;
const trackingPayload = {
service: savedSettings.service,
};
const ignoredKeys = ['shortener_credentials'];
for( const [key, value] of Object.entries(savedSettings.data) ){
if ( value === undefined || value === null || value === '' ) {
continue;
}
if ( ignoredKeys.includes(key) ) {
continue;
}
if ( 'interval_f' === key && 'fixed' === savedSettings.data?.type ) {
trackingPayload['interval_f_time'] = value?.time?.join(',');
trackingPayload['interval_f_weekdays'] = value?.week_days?.join(',');
}
if( Array.isArray(value) || typeof value === 'object' ){
continue;
}
trackingPayload[key] = value;
}
window?.tiTrk?.with('tweet')?.add({
feature: 'post-format',
featureComponent: 'saved-settings',
featureData: trackingPayload,
groupId: this.selected_account,
});
window?.tiTrk?.uploadEvents();
}, error => {
this.is_loading = false;
Vue.$log.error('Got nothing from server. Prompt user to check internet connection and try again', error)
})
});
},
getIcon(account) {
Expand Down
54 changes: 53 additions & 1 deletion vue/src/vue-elements/main-page-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,29 @@
target="_blank"
class="btn rop-sidebar-action-btns"
>{{ labels.review_it }}</a>
<div class="rop-tracking-box">
<h5>{{ labels.global_settings_header }}</h5>
<div class="rop-tracking-item">
<label
class="form-checkbox"
>
<input
v-model="tracking"
type="checkbox"
name="rop-tracking"
@change="toggle_tracking()"
>
<i class="form-icon" />
{{ labels.tracking }}
<a
:href="tracking_info_link"
target="_blank"
>
{{ labels.tracking_info }}
</a>
</label>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -226,7 +249,9 @@
staging: ropApiSettings.staging,
is_loading: false,
is_loading_logs: false,
status_is_error_display: false
status_is_error_display: false,
tracking: this.$store.state.tracking,
tracking_info_link: ropApiSettings.tracking_info_link
}
},
computed: {
Expand Down Expand Up @@ -453,6 +478,23 @@
Vue.$log.error('Got nothing from server. Prompt user to check internet connection and try again', error)
this.is_loading_logs = false;
})
},
/**
* Toggle tracking from SDK (via tiTrk).
*/
toggle_tracking() {
this.$log.info('Toggling tracking');
this.$store.dispatch('fetchAJAXPromise', {
req: 'toggle_tracking',
data: { tracking: Boolean( this.tracking) }
}).then(response => {
// Update tracking state.
this.$store.commit('updateState', {stateData: {tracking: Boolean( response?.tracking)}, requestName: 'toggle_tracking'});
this.$log.info('Succesfully toggled tracking.');
}, error => {
Vue.$log.error('Got nothing from server. Prompt user to check internet connection and try again', error)
})
}
}
}
Expand All @@ -477,4 +519,14 @@
#rop_core .badge.badge-logs {
padding-right: 10px;
}
.rop-tracking-box {
display: flex;
flex-direction: column;
gap: 8px;
padding: 0.25rem 0.4rem;
border: 0.05rem solid #042440;
border-radius: 0.1rem;
}
</style>
Loading

0 comments on commit b03d835

Please sign in to comment.