Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
picocodes committed Jan 12, 2025
1 parent 013bc53 commit e912d69
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 14 deletions.
19 changes: 15 additions & 4 deletions build/Emails/Types/Recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public function about_automation( $about, $campaign ) {
'<div class="noptin-strong %s noptin-tip" title="%s">%s</div>',
$error,
esc_attr( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next_send + ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ),
esc_html( $this->get_formatted_next_send_time( $next_send, wp_parse_id_list( $campaign->get( 'skip_days' ) ) ) )
wp_kses_post( $this->get_formatted_next_send_time( $next_send, wp_parse_id_list( $campaign->get( 'skip_days' ) ) ) )
);

// If we have a next send time, but no cron event, display a warning.
Expand Down Expand Up @@ -681,9 +681,20 @@ private function get_formatted_next_send_time( $timestamp, $skip_days = array()
// If past, abort.
if ( $timestamp < $now ) {
return sprintf(
// translators: %1 is the time.
__( 'Was supposed to be send %1$s ago', 'newsletter-optin-box' ),
human_time_diff( $timestamp, $now )
'%s. %s',
sprintf(
// translators: %1 is the time.
__( 'Was supposed to be send %1$s ago', 'newsletter-optin-box' ),
human_time_diff( $timestamp, $now )
),
sprintf(
'<a href="https://cronwp.com" target="_blank">%s</a>',
sprintf(
// translators: %s is the cron URL.
__( 'Set up an external cron job for "%s" to fix such issues.', 'newsletter-optin-box' ),
home_url( '/' ) . 'wp-cron.php'
)
)
);
}

Expand Down
2 changes: 1 addition & 1 deletion build/Emails/assets/js/email-editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '6ae81294a444bf1752cd');
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-data-controls', 'wp-date', 'wp-deprecated', 'wp-dom', 'wp-editor', 'wp-element', 'wp-format-library', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-keyboard-shortcuts', 'wp-keycodes', 'wp-media-utils', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-rich-text', 'wp-url'), 'version' => '2aff7e3d73026b9b6647');
2 changes: 1 addition & 1 deletion build/Emails/assets/js/email-editor.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion includes/class-noptin-dynamic-content-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,13 @@ public function check_conditional_logic( $conditional_logic, $skip_tags = array(
}

// If the rule is met.
if ( noptin_is_conditional_logic_met( $current_value, $compare_value, $rule['condition'] ) ) {
$is_met = noptin_is_conditional_logic_met( $current_value, $compare_value, $rule['condition'] );

if ( ! $is_met ) {
noptin_error_log( 'Conditional logic rule not met: ' . json_encode( compact( 'current_value', 'compare_value', 'rule' ) ) );
}

if ( $is_met ) {

// If we're using the "any" condition, we can stop here.
if ( 'any' === $type ) {
Expand Down
4 changes: 4 additions & 0 deletions templates/email-templates/noptin-visual/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@
vertical-align: bottom;
}

table.noptin-image-block__wrapper div {
overflow: hidden;
}

table.noptin-button-block__wrapper {
border-collapse: separate;
width: 100%;
Expand Down
77 changes: 70 additions & 7 deletions vendor/hizzle/store/src/REST_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,12 @@ public function get_items( $request ) {
$items[] = $this->prepare_response_for_collection( $data );
}

$per_page = (int) $query->query_vars['per_page'];
$total = (int) $query->get_total();
$paged = (int) $query->query_vars['page'];

$max_pages = $total > 0 && $per_page > 1 ? ceil( $total / $per_page ) : 1;

$response = rest_ensure_response(
apply_filters(
$this->prefix_hook( 'get_items' ),
Expand All @@ -570,15 +576,50 @@ public function get_items( $request ) {
'value' => $query->get_total(),
),
),
'total' => $query->get_total(),
'total' => $total,
),
$query,
$request,
$this
)
);

$response->header( 'X-WP-Total', $query->get_total() );
/*
$response = rest_ensure_response(
apply_filters(
$this->prefix_hook( 'get_items' ),
$items,
$query,
$request,
$this
)
);
*/

// Add headers.
$response->header( 'X-WP-Total', $total );
$response->header( 'X-WP-TotalPages', $max_pages );

$request_params = $request->get_query_params();
$collection_url = rest_url( $this->namespace . '/' . $this->rest_base );
$base = add_query_arg( urlencode_deep( $request_params ), $collection_url );

if ( $paged > 1 ) {
$prev_page = $paged - 1;

if ( $prev_page > $max_pages ) {
$prev_page = $max_pages;
}

$prev_link = add_query_arg( 'paged', $prev_page, $base );
$response->link_header( 'prev', $prev_link );
}

if ( $max_pages > $paged ) {
$next_page = $paged + 1;
$next_link = add_query_arg( 'paged', $next_page, $base );
$response->link_header( 'next', $next_link );
}

return $response;
}
Expand All @@ -594,8 +635,12 @@ public function get_items( $request ) {
public function get_item( $request ) {
$object = $this->get_object( $request );

if ( is_wp_error( $object ) ) {
return $object;
}

if ( ! $object || ! $object->exists() ) {
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) );
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) );
}

$data = $this->prepare_item_for_response( $object, $request );
Expand All @@ -615,8 +660,12 @@ public function get_item( $request ) {
public function get_item_overview( $request ) {
$object = $this->get_object( $request );

if ( is_wp_error( $object ) ) {
return $object;
}

if ( ! $object || ! $object->exists() ) {
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) );
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) );
}

return rest_ensure_response( array_values( $object->get_overview() ) );
Expand All @@ -634,8 +683,12 @@ public function get_item_overview( $request ) {
public function remote_action( $request ) {
$object = $this->get_object( $request );

if ( is_wp_error( $object ) ) {
return $object;
}

if ( ! $object || ! $object->exists() ) {
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 404 ) );
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) );
}

$action = $request['action'];
Expand Down Expand Up @@ -718,6 +771,10 @@ public function update_item( $request ) {

$object = $this->get_object( $request );

if ( is_wp_error( $object ) ) {
return $object;
}

if ( ! $object || ! $object->exists() ) {
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) );
}
Expand Down Expand Up @@ -755,10 +812,16 @@ public function delete_item( $request ) {
$object = $this->get_object( $request );
$force = isset( $request['force'] ) ? (bool) $request['force'] : false;

if ( $object->exists() ) {
$object->delete( $force );
if ( is_wp_error( $object ) ) {
return $object;
}

if ( empty( $object ) || ! $object->exists() ) {
return new \WP_Error( $this->prefix_hook( 'not_found' ), __( 'Record not found.', 'hizzle-store' ), array( 'status' => 400 ) );
}

$object->delete( $force );

return new \WP_REST_Response( true, 204 );
}

Expand Down

0 comments on commit e912d69

Please sign in to comment.