Skip to content

Commit a5af910

Browse files
chore: re-structure
Add the JS and CSS into a single PHP file since it will used only one time
1 parent 13b88ee commit a5af910

File tree

4 files changed

+286
-223
lines changed

4 files changed

+286
-223
lines changed

css/settings.css

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,50 +2865,3 @@ button.feedzy-action-button {
28652865
gap: 1rem;
28662866
margin-bottom: 20px;
28672867
}
2868-
2869-
2870-
.feedzy-notice-dismiss {
2871-
position: absolute;
2872-
top: 10px;
2873-
right: 10px;
2874-
background: transparent;
2875-
border: none;
2876-
cursor: pointer;
2877-
font-size: 24px;
2878-
}
2879-
2880-
.feedzy-notice-title {
2881-
font-size: clamp(28px, 5vw, 42px);
2882-
margin: 0 0 10px 0;
2883-
}
2884-
2885-
.feedzy-helper-notice .feedzy-notice-subtitle {
2886-
font-size: 20px;
2887-
margin-bottom: 20px;
2888-
}
2889-
2890-
.feedzy-wrap .feedzy-helper-subscribe {
2891-
width: 100%;
2892-
max-width: 600px;
2893-
padding: 15px;
2894-
font-size: 16px;
2895-
border: none;
2896-
border-radius: 5px;
2897-
margin-bottom: 20px;
2898-
}
2899-
2900-
.feedzy-helper-info {
2901-
font-size: 18px;
2902-
font-weight: 600;
2903-
margin-bottom: 8px;
2904-
}
2905-
2906-
.feedzy-helper-notice .feedzy-subscribe{
2907-
background: white;
2908-
padding: 12px 30px;
2909-
font-size: 18px;
2910-
font-weight: 600;
2911-
border: none;
2912-
border-radius: 5px;
2913-
cursor: pointer;
2914-
}

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,6 +2160,7 @@ private function setup_wizard_subscribe_process() {
21602160
if ( ! is_wp_error( $request_res ) ) {
21612161
$body = json_decode( wp_remote_retrieve_body( $request_res ) );
21622162
if ( 'success' === $body->code ) {
2163+
update_option( 'feedzy_onboarding_user_subscribed', 'yes' );
21632164
$this->feedzy_dismiss_wizard( false );
21642165
wp_send_json( $response );
21652166
}
@@ -2172,14 +2173,14 @@ private function setup_wizard_subscribe_process() {
21722173
)
21732174
);
21742175
} else {
2175-
update_option( 'feedzy_rss_feeds_skip_subscribe', 'yes' );
2176+
21762177
$this->feedzy_dismiss_wizard( false );
21772178
wp_send_json( $response );
21782179
}
21792180
}
21802181

21812182
/**
2182-
* AJAX method to subscribe user to Feedzy newsletter.
2183+
* AJAX method to subscribe user to Feedzy newsletter via dashboard notice.
21832184
*
21842185
* @since 5.1.0
21852186
* @access public
@@ -2188,40 +2189,51 @@ private function setup_wizard_subscribe_process() {
21882189
public function feedzy_dashboard_subscribe() {
21892190
check_ajax_referer( 'feedzy_subscribe_nonce', '_wpnonce' );
21902191

2191-
$with_subscribe = ! empty( $_POST['with_subscribe'] ) ? (bool) $_POST['with_subscribe'] : false;
2192-
$email = ! empty( $_POST['email'] ) ? sanitize_email( $_POST['email'] ) : '';
2193-
$integrate_with = ! empty( $_POST['integrate_with'] ) ? sanitize_text_field( $_POST['integrate_with'] ) : '';
2194-
2195-
if ( $with_subscribe && is_email( $email ) ) {
2196-
update_option( 'feedzy_rss_feeds_logger_flag', 'yes' );
2197-
2198-
$request_res = wp_remote_post(
2199-
FEEDZY_SUBSCRIBE_API,
2192+
$email = ! empty( $_POST['email'] ) ? sanitize_email( $_POST['email'] ) : '';
2193+
$skip = ! empty( $_POST['skip'] ) ? sanitize_text_field( wp_unslash( $_POST['skip'] ) ) : '';
2194+
2195+
if ( 'yes' === $skip ) {
2196+
$this->dismiss_subscribe_notice();
2197+
wp_send_json_success();
2198+
}
2199+
2200+
if ( empty( $email ) || ! is_email( $email ) ) {
2201+
wp_send_json_error(
22002202
array(
2201-
'timeout' => 100, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
2202-
'headers' => array(
2203-
'Content-Type' => 'application/json',
2204-
),
2205-
'body' => wp_json_encode(
2206-
array(
2207-
'slug' => 'feedzy-rss-feeds',
2208-
'site' => home_url(),
2209-
'email' => $email,
2210-
'data' => array( 'integration' => $integrate_with ),
2211-
)
2212-
),
2203+
'message' => __( 'Validation failed', 'feedzy-rss-feeds' ),
22132204
)
22142205
);
2215-
2216-
if ( ! is_wp_error( $request_res ) ) {
2217-
$this->dismiss_subscribe_notice();
2218-
wp_send_json_success();
2219-
} else {
2220-
wp_send_json_error();
2221-
}
2222-
} else {
2206+
}
2207+
2208+
update_option( 'feedzy_rss_feeds_logger_flag', 'yes' );
2209+
2210+
$request_res = wp_remote_post(
2211+
FEEDZY_SUBSCRIBE_API,
2212+
array(
2213+
'timeout' => 100, // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout
2214+
'headers' => array(
2215+
'Content-Type' => 'application/json',
2216+
),
2217+
'body' => wp_json_encode(
2218+
array(
2219+
'slug' => 'feedzy-rss-feeds',
2220+
'site' => home_url(),
2221+
'email' => $email,
2222+
'data' => array( 'source' => 'dashboard-notice' ),
2223+
)
2224+
),
2225+
)
2226+
);
2227+
2228+
if ( ! is_wp_error( $request_res ) ) {
22232229
$this->dismiss_subscribe_notice();
22242230
wp_send_json_success();
2231+
} else {
2232+
wp_send_json_error(
2233+
array(
2234+
'message' => $request_res->get_error_message(),
2235+
)
2236+
);
22252237
}
22262238
}
22272239

@@ -2233,7 +2245,7 @@ public function feedzy_dashboard_subscribe() {
22332245
* @return void
22342246
*/
22352247
public function dismiss_subscribe_notice() {
2236-
update_option( 'feedzy_rss_feeds_dismiss_subscribe_notice', 'yes' );
2248+
update_option( 'feedzy_dismiss_subscribe_notice_dashboard', 'yes' );
22372249
}
22382250

22392251
/**

0 commit comments

Comments
 (0)