Skip to content

Commit d90fa86

Browse files
Merge branch 'develop'
2 parents b673bc3 + 249c315 commit d90fa86

33 files changed

+856
-580
lines changed

.wordpress-org/banner-1544x500.png

108 KB
Loading

.wordpress-org/banner-772x250.png

-110 KB
Loading

assets/build/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '527d9c316c5b0cf85f14');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '7fd38c9fb0b998c4cff7');

assets/build/index.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,6 +3426,9 @@ select {
34263426
.wedocs-document :is(.mr-6) {
34273427
margin-right: 1.5rem;
34283428
}
3429+
.wedocs-document :is(.mr-\[20px\]) {
3430+
margin-right: 20px;
3431+
}
34293432
.wedocs-document :is(.mr-auto) {
34303433
margin-right: auto;
34313434
}
@@ -3770,6 +3773,9 @@ select {
37703773
.wedocs-document :is(.max-w-md) {
37713774
max-width: 28rem;
37723775
}
3776+
.wedocs-document :is(.max-w-none) {
3777+
max-width: none;
3778+
}
37733779
.wedocs-document :is(.flex-1) {
37743780
flex: 1 1 0%;
37753781
}
@@ -3896,6 +3902,9 @@ select {
38963902
.wedocs-document :is(.\!gap-6) {
38973903
gap: 1.5rem !important;
38983904
}
3905+
.wedocs-document :is(.gap-0) {
3906+
gap: 0px;
3907+
}
38993908
.wedocs-document :is(.gap-1) {
39003909
gap: 0.25rem;
39013910
}
@@ -4585,6 +4594,9 @@ select {
45854594
.wedocs-document :is(.pr-9) {
45864595
padding-right: 2.25rem;
45874596
}
4597+
.wedocs-document :is(.pr-\[5px\]) {
4598+
padding-right: 5px;
4599+
}
45884600
.wedocs-document :is(.pt-0) {
45894601
padding-top: 0px;
45904602
}
@@ -4671,6 +4683,9 @@ select {
46714683
.wedocs-document :is(.\!font-normal) {
46724684
font-weight: 400 !important;
46734685
}
4686+
.wedocs-document :is(.font-\[600\]) {
4687+
font-weight: 600;
4688+
}
46744689
.wedocs-document :is(.font-bold) {
46754690
font-weight: 700;
46764691
}

assets/build/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/build/store.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-api-fetch', 'wp-data'), 'version' => 'c1214b96c67fdae5b833');
1+
<?php return array('dependencies' => array('wp-api-fetch', 'wp-data'), 'version' => '78242b4acd2636b2c462');

assets/build/store.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/img/wedocs-icon-128x128.png

6.5 KB
Loading

includes/API/API.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,22 @@ public function register_routes() {
233233
],
234234
],
235235
] );
236+
237+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/promotion-notice', [
238+
[
239+
'methods' => WP_REST_Server::READABLE,
240+
'callback' => [ $this, 'get_promotional_notice' ],
241+
'permission_callback' => [ $this, 'get_promotional_notice_check' ],
242+
]
243+
] );
244+
245+
register_rest_route( $this->namespace, '/' . $this->rest_base . '/hide-promotion-notice', [
246+
[
247+
'methods' => WP_REST_Server::CREATABLE,
248+
'callback' => [ $this, 'handle_hide_promotion_notice' ],
249+
'permission_callback' => [ $this, 'get_promotional_notice_check' ],
250+
]
251+
] );
236252
}
237253

238254
/**
@@ -835,4 +851,98 @@ public function remove_child_docs( $parent_id ) {
835851
}
836852
}
837853
}
854+
855+
/**
856+
* Check permissions for getting
857+
* promotion notice.
858+
*
859+
* @since 2.1.11
860+
*
861+
* @param WP_REST_Request $request Current request.
862+
*
863+
* @return bool|WP_Error
864+
*/
865+
public function get_promotional_notice_check( $request ) {
866+
if ( ! current_user_can( 'manage_options' ) ) {
867+
return new WP_Error(
868+
'wedocs_permission_failure',
869+
__( 'You cannot see promotion notices.', 'wedocs' )
870+
);
871+
}
872+
873+
return true;
874+
}
875+
876+
/**
877+
* Get the data needed for promotional notice.
878+
*
879+
* @since 2.1.11
880+
*
881+
* @return bool|WP_Error|WP_REST_Response response object on success, or WP_Error object on failure.
882+
*/
883+
public function get_promotional_notice() {
884+
if ( ! current_user_can( 'manage_options' ) ) {
885+
return false;
886+
}
887+
888+
$promos = get_transient( WEDOCS_PROMO_KEY );
889+
890+
if ( false === $promos ) {
891+
$promo_notice_url = WEDOCS_PROMO_URL;
892+
$response = wp_remote_get( $promo_notice_url, array( 'timeout' => 15 ) );
893+
$promos = wp_remote_retrieve_body( $response );
894+
$promos = json_decode( $promos, true );
895+
896+
if ( is_wp_error( $response ) || $response['response']['code'] !== 200 ) {
897+
$promos = '[]';
898+
}
899+
900+
set_transient( WEDOCS_PROMO_KEY, $promos, DAY_IN_SECONDS );
901+
}
902+
903+
$promos = ! is_array( $promos ) ? json_decode( $promos, true ) : $promos;
904+
905+
if ( empty( $promos ) || ! is_array( $promos ) ) {
906+
return false;
907+
}
908+
909+
if ( ! isset( $promos['key'] ) || 'hide' === get_option( $promos['key'], 'no' ) ) {
910+
return false;
911+
}
912+
913+
$promos['logo_url'] = WEDOCS_LOGO_URL;
914+
915+
$current_time = wedocs_convert_utc_to_est();
916+
917+
if (
918+
isset( $promos['start_date'] )
919+
&& isset( $promos['end_date'] )
920+
&& strtotime( $promos['start_date'] ) < strtotime( $current_time )
921+
&& strtotime( $current_time ) < strtotime( $promos['end_date'] )
922+
) {
923+
return rest_ensure_response( $promos );
924+
}
925+
926+
return false;
927+
}
928+
929+
/**
930+
* Handle promotional notice hidden action
931+
*
932+
* @since 2.1.11
933+
*
934+
* @param WP_REST_Request $request Current request.
935+
*
936+
*/
937+
public function handle_hide_promotion_notice( $request ) {
938+
if ( ! empty( $request->get_param('option_name') ) ) {
939+
$offer_key = sanitize_text_field( wp_unslash( $request->get_param('option_name') ) );
940+
941+
update_option( $offer_key, 'hide' );
942+
943+
wp_send_json_success( 'Successfully dismissed.' );
944+
}
945+
946+
wp_send_json_error( 'Faild to dismiss.' );
947+
}
838948
}

includes/Admin/Admin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public function __construct() {
1717
add_filter( 'submenu_file', [ $this, 'highlight_admin_submenu' ] );
1818
add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ], 1 );
1919
add_action( 'admin_notices', [ $this, 'show_wedocs_pro_available_notice' ] );
20+
21+
if ( ! wedocs_pro_exists() ) {
22+
new Promotion();
23+
}
2024
}
2125

2226
/**

0 commit comments

Comments
 (0)