Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #1037

Merged
merged 10 commits into from
Feb 25, 2025
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.

93 changes: 44 additions & 49 deletions includes/admin/class-rop-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ public function enqueue_scripts() {

$added_services = $services->get_authenticated_services();
$added_networks = 0;
$accounts_count = count( $added_services );
if ( $added_services ) {

$uniq_auth_accounts = array();
Expand Down Expand Up @@ -421,7 +422,29 @@ public function enqueue_scripts() {
wp_deregister_script( 'vue-libs' );
}

$this->register_survey();
$is_post_sharing_active = ( new Rop_Cron_Helper() )->get_status() ? 'yes' : 'no';

if ( ! defined( 'TI_E2E_TESTING' ) || ! TI_E2E_TESTING ) {
add_filter(
'themeisle-sdk/survey/' . ROP_PRODUCT_SLUG,
function( $data, $page_slug ) use ( $accounts_count, $is_post_sharing_active ) {
$data = $this->get_survey_metadata();

$extra_attributes = array(
'accounts_number' => min( 20, $accounts_count ),
'post_sharing_enabled' => $is_post_sharing_active,
);

$data['attributes'] = array_merge( $data['attributes'], $extra_attributes );

return $data;
},
10,
2
);
}
do_action( 'themeisle_internal_page', ROP_PRODUCT_SLUG, 'dashboard' );

if ( ! defined( 'ROP_PRO_VERSION' ) ) {
do_action( 'themeisle_sdk_load_banner', 'rop' );
}
Expand Down Expand Up @@ -1738,62 +1761,34 @@ public static function rop_check_reached_sharing_limit( $sharing_type = 'tw' ) {
* @return array The survey metadata.
*/
public function get_survey_metadata() {
$license_data = get_option( 'tweet_old_post_pro_license_data', array() );
$attributes = array();
$user_id = 'rop_' . ( ! empty( $license_data->key ) ? $license_data->key : preg_replace( '/[^\w\d]*/', '', get_site_url() ) ); // Use a normalized version of the site URL as a user ID for free users.
$license_status = apply_filters( 'product_rop_license_status', 'invalid' );
$license_plan = apply_filters( 'product_rop_license_plan', false );
$license_key = apply_filters( 'product_rop_license_key', false );

$install_days_number = intval( ( time() - get_option( 'rop_first_install_date', time() ) ) / DAY_IN_SECONDS );

$data = array(
'environmentId' => 'clwgcs7ia03df11mgz7gh15od',
'attributes' => array(
'license_status' => $license_status,
'free_version' => $this->version,
'install_days_number' => $install_days_number,
),
);

$days_since_install = round( ( time() - get_option( 'rop_first_install_date', 0 ) ) / DAY_IN_SECONDS );
$install_category = 0; // Normalized value.
if ( 0 === $days_since_install || 1 === $days_since_install ) {
$install_category = 0;
} elseif ( 1 < $days_since_install && 8 > $days_since_install ) {
$install_category = 7;
} elseif ( 8 <= $days_since_install && 31 > $days_since_install ) {
$install_category = 30;
} elseif ( 30 < $days_since_install && 90 > $days_since_install ) {
$install_category = 90;
} elseif ( 90 <= $days_since_install ) {
$install_category = 91;
if ( ! empty( $license_plan ) ) {
$data['attributes']['plan'] = strval( $license_plan );
}

$attributes['days_since_install'] = strval( $install_category );
$attributes['license_status'] = ! empty( $license_data->license ) ? $license_data->license : 'invalid';
$attributes['free_version'] = $this->version;

if ( ! empty( $license_data->plan ) ) {
$attributes['plan'] = strval( $license_data->plan );
if ( ! empty( $license_key ) ) {
$data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
}

if ( defined( 'ROP_PRO_VERSION' ) ) {
$attributes['pro_version'] = ROP_PRO_VERSION;
}

return array(
'userId' => $user_id,
'attributes' => $attributes,
);
}

/**
* Register the survey script.
*
* It does not register if we are in a testing environment.
*
* @return void
*/
public function register_survey() {

if ( defined( 'TI_E2E_TESTING' ) && TI_E2E_TESTING ) {
return;
}

$survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
if ( empty( $survey_handler ) ) {
return;
$data['attributes']['pro_version'] = ROP_PRO_VERSION;
}

do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
wp_localize_script( $survey_handler, 'ropSurveyData', $this->get_survey_metadata() );
return $data;
}

/**
Expand Down
11 changes: 11 additions & 0 deletions includes/admin/class-rop-global-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Rop_Global_Settings {
),
'allowed_accounts' => 1,
'description' => '',
'allowed_comment' => false,
),
'twitter' => array(
'active' => true,
Expand All @@ -105,41 +106,50 @@ class Rop_Global_Settings {
),
'two_step_sign_in' => true,
'allowed_accounts' => 1,
'allowed_comment' => false,
),
'linkedin' => array(
'active' => false,
'name' => 'LinkedIn',
'allowed_comment' => false,
),
'tumblr' => array(
'active' => false,
'name' => 'Tumblr',
'allowed_comment' => false,
),
'pinterest' => array(
'active' => false,
'name' => 'Pinterest',
'allowed_comment' => false,
),
'gmb' => array(
'active' => false,
'name' => 'Gmb',
'fullname' => 'Google My Business',
'allowed_comment' => false,
),
'vk' => array(
'active' => false,
'name' => 'Vk',
'allowed_comment' => false,
),
'webhook' => array(
'active' => false,
'name' => 'Webhook',
'two_step_sign_in' => true,
'allowed_comment' => false,
),
'telegram' => array(
'active' => false,
'name' => 'Telegram',
'allowed_comment' => false,
),
'mastodon' => array(
'active' => false,
'name' => 'Mastodon',
'two_step_sign_in' => true,
'allowed_comment' => false,
),
);

Expand Down Expand Up @@ -718,6 +728,7 @@ function ( $value ) {
$available_services['instagram'] = $available_services['facebook'];
$available_services['instagram']['name'] = 'Instagram';
$available_services['instagram']['active'] = $is_middle_plan ? true : false;
$available_services['instagram']['allowed_comment'] = false;
return $available_services;
}

Expand Down
1 change: 1 addition & 0 deletions tweet-old-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function run_rop() {
define( 'ROP_LITE_URL', plugin_dir_url( __FILE__ ) );
define( 'ROP_STATUS_ALERT', 6 ); // How many consecutive errors count towards status alert "Status: Error (check logs)"
define( 'ROP_TEMP_IMAGES', plugin_dir_path( __FILE__ ) . 'temp-images/' ); // Path for external images downloaded for sharing
define( 'ROP_PRODUCT_SLUG', basename( ROP_PATH ) );

// Authorization APP Data
define( 'ROP_AUTH_APP_URL', 'https://app.revive.social' );
Expand Down
15 changes: 1 addition & 14 deletions vue/src/rop_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,4 @@ window.addEventListener( 'load', function () {
store.dispatch( 'fetchAJAXPromise', {req: 'get_active_accounts'} )
},
} );
} );

/**
* Initialize the formbricks survey.
*
* @see https://github.com/formbricks/setup-examples/tree/main/html
*/
window.addEventListener('themeisle:survey:loaded', function () {
window?.tsdk_formbricks?.init?.({
environmentId: "clwgcs7ia03df11mgz7gh15od",
apiHost: "https://app.formbricks.com",
...(window?.ropSurveyData ?? {}),
});
});
} );
7 changes: 5 additions & 2 deletions vue/src/vue-elements/post-format.vue
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@
selected_tax_filter: [],
// selected_language: this.$store.state.activePostFormat[this.account_id] ? this.$store.state.activePostFormat[this.account_id].wpml_language : [],
// post_types: this.$store.state.generalSettings.available_post_types,
postCommentSupportedServices: [ 'twitter', 'facebook', 'linkedin', 'vk', 'mastodon' ],
}
},
computed: {
Expand Down Expand Up @@ -954,8 +953,12 @@
return Boolean( ! this.isPro && this.$store.state.is_new_user );
},
postCommentAllowed: function () {
var serviceName = this.allAccounts[this.account_id].service;
if ( this.is_instagram_account ) {
serviceName = 'instagram';
}
// Check if the service of the current account exists in allowedServices
return this.postCommentSupportedServices.includes(this.allAccounts[this.account_id].service);
return this.$store.state.availableServices[serviceName]?.allowed_comment;
},
},
watch: {
Expand Down
Loading