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 #895

Merged
merged 23 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4cf87da
feat: add black friday 2024 campaign
Soare-Robert-Daniel Jan 30, 2024
3ce87b1
feat: get black friday data from SDK
Soare-Robert-Daniel Jan 30, 2024
bc8c37b
chore: typo
Soare-Robert-Daniel Jan 30, 2024
9cfed4a
refactor: names
Soare-Robert-Daniel Jan 30, 2024
ecf9dfb
refactor: assets name
Soare-Robert-Daniel Jan 30, 2024
8cbd4b9
Merge branch 'development' into feat/black-friday-2024
Soare-Robert-Daniel Jan 30, 2024
1e2b970
chore: update phpdocs
Soare-Robert-Daniel Feb 7, 2024
1efed86
Merge branch 'development' into feat/black-friday-2024
Soare-Robert-Daniel Feb 7, 2024
f88d8b8
chore: update phpdoc
Soare-Robert-Daniel Feb 8, 2024
96a1b5a
Sync branch [skip ci]
pirate-bot Feb 9, 2024
5b85a52
Sync branch [skip ci]
pirate-bot Feb 9, 2024
6d42823
fix: try reuse image before generating
Soare-Robert-Daniel Feb 13, 2024
32bf8a3
feat: add nps survey
Soare-Robert-Daniel Feb 14, 2024
114c75c
feat: normalized url for user id survey
Soare-Robert-Daniel Feb 14, 2024
4782d62
feat: nps plan category & license status
Soare-Robert-Daniel Feb 15, 2024
2ecb1eb
chore: unknown nps plan category
Soare-Robert-Daniel Feb 15, 2024
211a349
refactor: CI env checking for survey loading
Soare-Robert-Daniel Feb 26, 2024
4c4fff2
refactor: use formbricks deps from SDK
Soare-Robert-Daniel Feb 27, 2024
28c36ab
Merge pull request #872 from Codeinwp/feat/black-friday-2024
vytisbulkevicius Feb 27, 2024
678455f
Bump codeinwp/themeisle-sdk from 3.3.13 to 3.3.14
dependabot[bot] Feb 27, 2024
06cd7c5
Merge pull request #890 from Codeinwp/fix/image-trigger
vytisbulkevicius Feb 27, 2024
affe579
Merge pull request #896 from Codeinwp/dependabot/composer/development…
vytisbulkevicius Feb 27, 2024
4524895
Merge pull request #891 from Codeinwp/feat/nps-survey
vytisbulkevicius Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Binary file modified img/black-friday-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ public function enqueue_styles_admin() {
wp_enqueue_script( $this->plugin_name . '_telemetry', FEEDZY_ABSURL . 'js/telemetry.js', array(), $this->version, true );
}

if ( 'feedzy_imports' === $screen->post_type && 'edit' === $screen->base ) {
$this->register_survey();
}

if ( 'feedzy_categories' === $screen->post_type ) {
wp_enqueue_script(
$this->plugin_name . '_categories',
Expand All @@ -152,6 +156,8 @@ public function enqueue_styles_admin() {
),
)
);

$this->register_survey();
}

if ( 'feedzy_page_feedzy-settings' === $screen->base ) {
Expand All @@ -171,6 +177,8 @@ public function enqueue_styles_admin() {
),
)
);

$this->register_survey();
}

$upsell_screens = array( 'feedzy-rss_page_feedzy-settings', 'feedzy-rss_page_feedzy-admin-menu-pro-upsell' );
Expand All @@ -195,6 +203,8 @@ public function enqueue_styles_admin() {
)
);
wp_enqueue_style( 'wp-block-editor' );

$this->register_survey();
}
if ( ! defined( 'TI_CYPRESS_TESTING' ) && ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type && feedzy_show_import_tour() ) ) {
wp_enqueue_script( $this->plugin_name . '_on_boarding', FEEDZY_ABSURL . 'js/Onboarding/import-onboarding.min.js', array( 'react', 'react-dom', 'wp-editor', 'wp-api', 'lodash' ), $this->version, true );
Expand All @@ -205,6 +215,9 @@ public function enqueue_styles_admin() {
}

if ( 'feedzy_page_feedzy-support' === $screen->base || ( 'edit' !== $screen->base && 'feedzy_imports' === $screen->post_type ) ) {

$this->register_survey();

wp_enqueue_script( $this->plugin_name . '_feedback', FEEDZY_ABSURL . 'js/FeedBack/feedback.min.js', array( 'react', 'react-dom', 'wp-editor', 'wp-api', 'lodash' ), $this->version, true );
wp_enqueue_style( 'wp-block-editor' );

Expand Down Expand Up @@ -1565,10 +1578,13 @@ public function api_license_status() {
'spinnerChiefStatus' => false,
'wordaiStatus' => false,
'openaiStatus' => false,
'amazonStatus' => false,
);

if ( ! feedzy_is_pro() ) {
return $data;
}

if ( apply_filters( 'feedzy_is_license_of_type', false, 'agency' ) ) {
if ( isset( $pro_options['spinnerchief_licence'] ) && 'yes' === $pro_options['spinnerchief_licence'] ) {
$data['spinnerChiefStatus'] = true;
Expand All @@ -1577,11 +1593,119 @@ public function api_license_status() {
$data['wordaiStatus'] = true;
}
}

if ( isset( $pro_options['openai_licence'] ) && 'yes' === $pro_options['openai_licence'] ) {
if ( apply_filters( 'feedzy_is_license_of_type', false, 'business' ) || apply_filters( 'feedzy_is_license_of_type', false, 'agency' ) ) {
$data['openaiStatus'] = true;
}
}

if ( ! empty( $pro_options['amazon_access_key'] ) && ! empty( $pro_options['amazon_secret_key'] ) ) {
$data['amazonStatus'] = true;
}
return $data;
}

/**
* Get the plan category for the product plan ID.
*
* @param object $license_data The license data.
* @return int
*/
private static function plan_category( $license_data ) {

if ( ! isset( $license_data->plan ) || ! is_numeric( $license_data->plan ) ) {
return 0; // Free
}

$plan = (int) $license_data->plan;
$current_category = -1;

$categories = array(
'1' => array(1, 4, 9), // Personal
'2' => array(2, 5, 8), // Business/Developer
'3' => array(3, 6, 7, 10), // Agency
);

foreach ( $categories as $category => $plans ) {
if ( in_array( $plan, $plans, true ) ) {
$current_category = (int) $category;
break;
}
}

return $current_category;
}

/**
* Get the data used for the survey.
*
* @return array
* @see survey.js
*/
public function get_survery_metadata() {

$user_id = 'feedzy_';
$license_data = get_option( 'feedzy_rss_feeds_pro_license_data', array() );

if ( ! empty( $license_data->key ) ) {
$user_id .= $license_data->key;
} else {
$user_id .= preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID for free users.
}

$integration_status = $this->api_license_status();

$days_since_install = round( ( time() - get_option( 'feedzy_rss_feeds_install', 0 ) ) / DAY_IN_SECONDS );
$install_category = 0;
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;
}

return array(
'userId' => $user_id,
'attributes' => array(
'free_version' => $this->version,
'pro_version' => defined( 'FEEDZY_PRO_VERSION' ) ? FEEDZY_PRO_VERSION : '',
'openai' => $integration_status['openaiStatus'] ? 'valid' : 'invalid',
'amazon' => $integration_status['amazonStatus'] ? 'valid' : 'invalid',
'spinnerchief' => $integration_status['spinnerChiefStatus'] ? 'valid' : 'invalid',
'wordai' => $integration_status['wordaiStatus'] ? 'valid' : 'invalid',
'plan' => $this->plan_category( $license_data ),
'days_since_install' => $install_category,
'license_status' => ! empty( $license_data->license ) ? $license_data->license : 'invalid',
),
);
}

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

if ( defined( 'CYPRESS_TESTING' ) ) {
return;
}

$survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
if ( empty( $survey_handler ) ) {
return;
}

do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
wp_enqueue_script( $this->plugin_name . '_survey', FEEDZY_ABSURL . 'js/survey.js', array( $survey_handler ), $this->version, true );
wp_localize_script( $this->plugin_name . '_survey', 'feedzySurveyData', $this->get_survery_metadata() );
}
}
55 changes: 41 additions & 14 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1818,22 +1818,25 @@ function( $term ) {
}
}

// Item image action.
$import_featured_img = rawurldecode( $import_featured_img );
$import_featured_img = trim( $import_featured_img );
$img_action = $this->handle_content_actions( $import_featured_img, 'item_image' );
// Item image action process.
$image_url = $img_action->run_action_job( $import_featured_img, $import_translation_lang, $job, $language_code, $item, $image_url );

if ( ! empty( $image_url ) ) {
if ( 'yes' === $import_item_img_url ) {
// Set external image URL.
update_post_meta( $new_post_id, 'feedzy_item_external_url', $image_url );
} else {
// if import_featured_img is a tag.
$img_success = $this->generate_featured_image( $image_url, $new_post_id, $item['item_title'], $import_errors, $import_info );
if ( 'yes' === $import_item_img_url || ! $this->tryReuseExistingFeaturedImage( $img_success, $item['item_title'], $new_post_id ) ) {
// Item image action.
$import_featured_img = rawurldecode( $import_featured_img );
$import_featured_img = trim( $import_featured_img );
$img_action = $this->handle_content_actions( $import_featured_img, 'item_image' );
// Item image action process.
$image_url = $img_action->run_action_job( $import_featured_img, $import_translation_lang, $job, $language_code, $item, $image_url );

if ( ! empty( $image_url ) ) {
if ( 'yes' === $import_item_img_url ) {
// Set external image URL.
update_post_meta( $new_post_id, 'feedzy_item_external_url', $image_url );
} else {
// if import_featured_img is a tag.
$img_success = $this->generate_featured_image( $image_url, $new_post_id, $item['item_title'], $import_errors, $import_info );
}
}
}

// Set default thumbnail image.
if ( ! $img_success && ! empty( $default_thumbnail ) ) {
$img_success = set_post_thumbnail( $new_post_id, $default_thumbnail );
Expand Down Expand Up @@ -1940,6 +1943,30 @@ public function get_job_feed( $options, $import_content = null, $raw_feed_also =
return $feed_items;
}

/**
* Reuses an existing featured image if possible.
*
* @param int|bool $result The result of the operation. It can be a boolean or an attachment ID.
* @param string $title_feed The title of the feed.
* @param int $post_id The post ID.
*
* @return bool
*/
public function tryReuseExistingFeaturedImage( &$result, $title_feed, $post_id = 0 ) {
if ( ! function_exists( 'post_exists' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
}
// Find existing attachment by feed title.
$attachment_id = post_exists( $title_feed, '', '', 'attachment' );

if ( ! $attachment_id ) {
return false;
}

$result = set_post_thumbnail( $post_id, $attachment_id );
return true;
}

/**
* Downloads and sets a post featured image if possible.
*
Expand Down
Loading
Loading