| @@ -81,9 +81,14 @@ | ||
| 81 | 81 | |
| 82 | 82 | // for admin scripts & styles |
| 83 | 83 | add_action( 'admin_enqueue_scripts', [ $this, 'wml_admin_enqueue_scripts' ] ); |
| 84 | 84 | |
| 85 | + add_action( 'admin_notices', [ $this, 'add_review_notice' ] ); | |
| 85 | 86 | |
| 87 | + add_filter( 'admin_footer_text', [ $this, 'admin_footer_text' ] ); | |
| 88 | + | |
| 89 | + add_action( 'admin_init', [ $this, 'wpv_mail_review' ], 10 ); | |
| 90 | + | |
| 86 | 91 | // Add Script type module |
| 87 | 92 | add_filter('script_loader_tag', [ $this, 'add_type_attribute' ] , 10, 3); |
| 88 | 93 | } |
| 89 | 94 | |
| @@ -119,15 +124,14 @@ | ||
| 119 | 124 | * @access public |
| 120 | 125 | * |
| 121 | 126 | */ |
| 122 | 127 | public function wpml_settings() { |
| 123 | - $setting_pages_keys = [ 'general' ]; | |
| 128 | + if ( isset( $_GET['wml_nonce'] ) && ! wp_verify_nonce( $_GET['wml_nonce'], 'wp_rest' ) ) { | |
| 129 | + die( 'Sorry, your nonce did not verify!' ); | |
| 130 | + } | |
| 124 | 131 | |
| 125 | 132 | if ( isset( $_GET['tab'] ) ) { |
| 126 | - $tab = sanitize_key( wp_unslash( $_GET['tab'] ) ); | |
| 127 | - if ( in_array( $tab, $setting_pages_keys, true ) ) { | |
| 128 | - $this->current_tab = $tab; | |
| 129 | - } | |
| 133 | + $this->current_tab = sanitize_text_field( wp_unslash( $_GET['tab'] ) ); | |
| 130 | 134 | } |
| 131 | 135 | |
| 132 | 136 | $setting_pages = [ |
| 133 | 137 | 'general' => __( 'General', 'wpv-wml' ), |
| @@ -141,9 +145,9 @@ | ||
| 141 | 145 | <nav class="wml-nav-tab-wrapper"> |
| 142 | 146 | <?php |
| 143 | 147 | foreach ( $setting_pages as $key => $label ) { |
| 144 | 148 | ?> |
| 145 | - <a class="wml-nav-tab <?php echo ( ( '' === $this->current_tab && 'general' === $key ) || $key === $this->current_tab ) ? 'wml-tab-active' : ''; ?>" href="admin.php?page=wpv-wpml-settings&tab=<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></a> | |
| 149 | + <a class="wml-nav-tab <?php echo ( ( '' === $this->current_tab && 'general' === $key ) || $key === $this->current_tab ) ? 'wml-tab-active' : ''; ?>" href="admin.php?page=wpv-wpml-settings&tab=<?php echo esc_html( $key . add_query_arg( 'wml_nonce', wp_create_nonce( 'wp_rest' ) ) ); ?>"><?php echo esc_html( $label ); ?></a> | |
| 146 | 150 | <?php |
| 147 | 151 | } |
| 148 | 152 | ?> |
| 149 | 153 | </nav> |
| @@ -166,8 +170,31 @@ | ||
| 166 | 170 | </div> |
| 167 | 171 | <?php |
| 168 | 172 | } |
| 169 | 173 | |
| 174 | + public function add_review_notice() { | |
| 175 | + if ( is_admin() ) { | |
| 176 | + $remind_later = get_transient( 'wml_remind_later' ); | |
| 177 | + | |
| 178 | + $wml_review = get_option( 'wml_review' ); | |
| 179 | + | |
| 180 | + if ( $wml_review === 'done' || $remind_later ) { | |
| 181 | + return; | |
| 182 | + } | |
| 183 | + | |
| 184 | + global $wpdb; | |
| 185 | + $rowcount = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}wml_entries" ); | |
| 186 | + | |
| 187 | + if ( $rowcount > 10 ) { | |
| 188 | + $this->wml_review_box(); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } | |
| 192 | + | |
| 193 | + public function sidebar() { | |
| 194 | + echo '<div>Sidebar Content</div>'; | |
| 195 | + } | |
| 196 | + | |
| 170 | 197 | /** |
| 171 | 198 | * Create Header |
| 172 | 199 | * |
| 173 | 200 | * Create header for our plugin pages |
| @@ -297,9 +324,9 @@ | ||
| 297 | 324 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 298 | 325 | 'ajax_nonce' => wp_create_nonce( 'wml_ajax_nonce' ), |
| 299 | 326 | 'locale' => get_locale(), |
| 300 | 327 | 'date-formate' => get_option( 'date_format' ), |
| 301 | - 'temp_date' => wp_date( get_option( 'date_format' ) ), | |
| 328 | + 'temp_date' => date( get_option( 'date_format' ) ), | |
| 302 | 329 | 'settings' => $settings, |
| 303 | 330 | 'upload_dir' => wp_upload_dir()['baseurl'], |
| 304 | 331 | ] |
| 305 | 332 | ); |
| @@ -382,8 +409,120 @@ | ||
| 382 | 409 | } |
| 383 | 410 | } |
| 384 | 411 | } |
| 385 | 412 | /** |
| 413 | + * Add Mail Review Notice | |
| 414 | + * | |
| 415 | + * @since 0.3 | |
| 416 | + * @return void | |
| 417 | + * @access public | |
| 418 | + * | |
| 419 | + */ | |
| 420 | + public function wpv_mail_review() { | |
| 421 | + if ( isset( $_GET['wml_remind_later'] ) || isset( $_GET['wml_review_done'] ) ) { | |
| 422 | + if ( ! empty( $_GET['wml_nonce'] ) && wp_verify_nonce( $_GET['wml_nonce'], 'wml_rest' ) ) { | |
| 423 | + | |
| 424 | + $user = \wp_get_current_user(); | |
| 425 | + $roles = (array) $user->roles; | |
| 426 | + if ( $roles[0] !== 'administrator' ) { | |
| 427 | + return; | |
| 428 | + } | |
| 429 | + | |
| 430 | + if ( isset( $_GET['wml_remind_later'] ) ) { | |
| 431 | + $this->wml_remind_later(); | |
| 432 | + } elseif ( | |
| 433 | + isset( $_GET['wml_review_done'] ) ) { | |
| 434 | + $this->wml_review_done(); | |
| 435 | + } | |
| 436 | + } | |
| 437 | + } | |
| 438 | + } | |
| 439 | + /** | |
| 440 | + * Set Notice to Remind Later | |
| 441 | + * | |
| 442 | + * @since 0.3 | |
| 443 | + * @return void | |
| 444 | + * @access public | |
| 445 | + * | |
| 446 | + */ | |
| 447 | + public function wml_remind_later() { | |
| 448 | + set_transient( 'wml_remind_later', 'show again', WEEK_IN_SECONDS ); | |
| 449 | + } | |
| 450 | + /** | |
| 451 | + * Set Review Notice to Done | |
| 452 | + * | |
| 453 | + * @since 0.3 | |
| 454 | + * @return void | |
| 455 | + * @access public | |
| 456 | + * | |
| 457 | + */ | |
| 458 | + public function wml_review_done() { | |
| 459 | + update_option( 'wml_review', 'done', false ); | |
| 460 | + } | |
| 461 | + | |
| 462 | + /** | |
| 463 | + * Review Notice HTML | |
| 464 | + * | |
| 465 | + * @since 0.3 | |
| 466 | + * @return void | |
| 467 | + * @access public | |
| 468 | + * | |
| 469 | + */ | |
| 470 | + | |
| 471 | + public function wml_review_box() { | |
| 472 | + ?> | |
| 473 | + <div class="wml-review notice notice-success is-dismissible"> | |
| 474 | + <div class="wml-logo"> | |
| 475 | + <svg viewBox="0 0 831 775" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | |
| 476 | + <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> | |
| 477 | + <g id="El-logo-blue" fill-rule="nonzero"> | |
| 478 | + <path d="M227.7,160.1 C227.7,155.8 229,151.8 231.3,148.5 C232.4,146.8 233.8,145.3 235.3,144.1 C238.9,141.1 243.5,139.3 248.5,139.3 L582.7,139.3 C587,139.3 591,140.6 594.3,142.9 C596.5,144.4 598.4,146.3 599.9,148.5 C602.1,151.8 603.5,155.8 603.5,160.1 L603.5,394.9 L830.8,257.3 L446.5,10.2 C427.4,-2.1 402.9,-2.1 383.8,10.2 L0.3,257.2 L227.6,394.8 L227.6,160.1 L227.7,160.1 Z" id="Path" fill="#154DAE"></path> | |
| 479 | + <path d="M599.9,148.5 C598.4,146.3 596.5,144.4 594.3,142.9 C591,140.7 587,139.3 582.7,139.3 L248.5,139.3 C243.5,139.3 238.9,141.1 235.3,144.1 C233.8,145.4 232.4,146.9 231.3,148.5 C229.1,151.8 227.7,155.8 227.7,160.1 L227.7,394.8 L283.2,428.4 L329.1,456.2 L382.3,488.4 C402.8,500.8 428.4,500.8 448.8,488.4 L503.7,455.7 L549.5,427.5 L603.4,394.9 L603.4,160.1 C603.5,155.8 602.2,151.8 599.9,148.5 Z M368.5,182.9 L462.7,182.9 C469.5,182.9 475,188.4 475,195.2 C475,202 469.5,207.5 462.7,207.5 L368.5,207.5 C361.7,207.5 356.2,202 356.2,195.2 C356.2,188.4 361.7,182.9 368.5,182.9 Z M495.6,384.8 L335.6,384.8 C328.8,384.8 323.3,379.3 323.3,372.5 C323.3,365.7 328.8,360.2 335.6,360.2 L495.6,360.2 C502.4,360.2 507.9,365.7 507.9,372.5 C507.9,379.3 502.4,384.8 495.6,384.8 Z M342.1,313.4 C342.1,306.6 347.6,301.1 354.4,301.1 L476.6,301.1 C483.4,301.1 488.9,306.6 488.9,313.4 C488.9,320.2 483.4,325.7 476.6,325.7 L354.5,325.7 C347.7,325.7 342.1,320.2 342.1,313.4 Z M515.5,266.6 L315.7,266.6 C308.9,266.6 303.4,261.1 303.4,254.3 C303.4,247.5 308.9,242 315.7,242 L515.5,242 C522.3,242 527.8,247.5 527.8,254.3 C527.8,261.1 522.3,266.6 515.5,266.6 Z" id="Shape" fill="#F2F2F2"></path> | |
| 480 | + <polygon id="Path" fill="#154DAE" points="101.1 694.3 329.1 456.2 283.2 428.4"></polygon> | |
| 481 | + <polygon id="Path" fill="#154DAE" points="732.3 694.3 549.6 427.5 503.8 455.7"></polygon> | |
| 482 | + <path d="M830.8,736.5 L830.8,257.2 L830.8,257.2 L603.5,394.8 L549.6,427.4 L732.4,694.2 L503.8,455.7 L448.9,488.4 C428.4,500.8 402.8,500.8 382.4,488.4 L329.2,456.2 L101.1,694.3 L283.2,428.4 L227.7,394.8 L0.4,257.2 L0.4,707.7 L0.4,736.5 C0.4,757.8 17.7,775 38.9,775 L792.3,775 C813.6,775 830.8,757.8 830.8,736.5 Z" id="Path" fill="#1B5ED7"></path> | |
| 483 | + <path d="M368.5,207.6 L462.7,207.6 C469.5,207.6 475,202.1 475,195.3 C475,188.5 469.5,183 462.7,183 L368.5,183 C361.7,183 356.2,188.5 356.2,195.3 C356.2,202.1 361.7,207.6 368.5,207.6 Z" id="Path" fill="#154DAE"></path> | |
| 484 | + <path d="M515.5,242 L315.7,242 C308.9,242 303.4,247.5 303.4,254.3 C303.4,261.1 308.9,266.6 315.7,266.6 L515.5,266.6 C522.3,266.6 527.8,261.1 527.8,254.3 C527.8,247.5 522.3,242 515.5,242 Z" id="Path" fill="#154DAE"></path> | |
| 485 | + <path d="M476.7,325.7 C483.5,325.7 489,320.2 489,313.4 C489,306.6 483.5,301.1 476.7,301.1 L354.5,301.1 C347.7,301.1 342.2,306.6 342.2,313.4 C342.2,320.2 347.7,325.7 354.5,325.7 L476.7,325.7 Z" id="Path" fill="#154DAE"></path> | |
| 486 | + <path d="M495.6,360.1 L335.6,360.1 C328.8,360.1 323.3,365.6 323.3,372.4 C323.3,379.2 328.8,384.7 335.6,384.7 L495.6,384.7 C502.4,384.7 507.9,379.2 507.9,372.4 C507.9,365.6 502.4,360.1 495.6,360.1 Z" id="Path" fill="#154DAE"></path> | |
| 487 | + </g> | |
| 488 | + </g> | |
| 489 | + </svg> | |
| 490 | + </div> | |
| 491 | + <div class="wml-review-content"> | |
| 492 | + <p class="wml-review-desc"><?php echo 'WP Mail Log has already captured 10+ mail log. That’s awesome! Could you please do a BIG favor and give it a 5-star rating on WordPress? <br/> Just to help us spread the word and boost our motivation. <br/><b>~ Anand Upadhyay</b>'; ?></p> | |
| 493 | + <span class="wml-notic-link-wrapper"> | |
| 494 | + <a class="wml-notice-link" target="_blank" href="https://wordpress.org/support/plugin/wp-mail-log/reviews/#new-post" class="button button-primary"><span class="dashicons dashicons-heart"></span><?php esc_html_e( 'Ok, you deserve it!', 'wpv-wml' ); ?></a> | |
| 495 | + <a class="wml-notice-link" href=" | |
| 496 | + <?php | |
| 497 | + echo esc_html( | |
| 498 | + add_query_arg( | |
| 499 | + [ | |
| 500 | + 'wml_remind_later' => 'later', | |
| 501 | + 'wml_nonce' => wp_create_nonce( 'wml_rest' ), | |
| 502 | + ] | |
| 503 | + ) | |
| 504 | + ) | |
| 505 | + ?> | |
| 506 | + "><span class="dashicons dashicons-schedule"></span><?php esc_html_e( 'May Be Later', 'wpv-wml' ); ?></a> | |
| 507 | + <a class="wml-notice-link" href=" | |
| 508 | + <?php | |
| 509 | + echo esc_html( | |
| 510 | + add_query_arg( | |
| 511 | + [ | |
| 512 | + 'wml_review_done' => 'done', | |
| 513 | + 'wml_nonce' => wp_create_nonce( 'wml_rest' ), | |
| 514 | + ] | |
| 515 | + ) | |
| 516 | + ); | |
| 517 | + ?> | |
| 518 | + "><span class="dashicons dashicons-smiley"></span><?php esc_html_e( 'Already Done', 'wpv-wml' ); ?></a> | |
| 519 | + </span> | |
| 520 | + </div> | |
| 521 | + </div> | |
| 522 | + <?php | |
| 523 | + } | |
| 524 | + /** | |
| 386 | 525 | * Fire on Plugin Activation Hook |
| 387 | 526 | * |
| 388 | 527 | * Write the function which will fire on plugin Activate. |
| 389 | 528 | * |
| @@ -419,9 +558,9 @@ | ||
| 419 | 558 | $date = date( 'Y-m-d', strtotime( '-' . $days . ' days' ) ); |
| 420 | 559 | |
| 421 | 560 | $table_name = $wpdb->prefix . 'wml_entries'; |
| 422 | 561 | |
| 423 | - $query = $wpdb->prepare( "DELETE FROM %i WHERE DATE_FORMAT(captured_gmt,GET_FORMAT(DATE,'JIS')) <= %s", $table_name, $date ); | |
| 562 | + $query = $wpdb->prepare( "DELETE FROM {$table_name} WHERE DATE_FORMAT(captured_gmt,GET_FORMAT(DATE,'JIS')) <= %s", $date ); | |
| 424 | 563 | |
| 425 | 564 | $dl1 = $wpdb->query( $query ); |
| 426 | 565 | |
| 427 | 566 | if ( $dl1 === 0 ) { |
| @@ -450,8 +589,37 @@ | ||
| 450 | 589 | wp_clear_scheduled_hook( 'wpv/wml/delete_logs' ); |
| 451 | 590 | } |
| 452 | 591 | |
| 453 | 592 | |
| 593 | + /** | |
| 594 | + * Update Admin Footer Text | |
| 595 | + * | |
| 596 | + * @since 0.3 | |
| 597 | + * @param string $footer_text Footer Text | |
| 598 | + * @return string updated $footer_text | |
| 599 | + * @access public | |
| 600 | + * | |
| 601 | + */ | |
| 602 | + | |
| 603 | + public function admin_footer_text( $footer_text ) { | |
| 604 | + $screen = get_current_screen(); | |
| 605 | + // Todo:: Show on plugin screens | |
| 606 | + $wml_screens = [ | |
| 607 | + 'toplevel_page_wp-mail-log', | |
| 608 | + 'wp-mail-log_page_wpv-wpml-settings', | |
| 609 | + ]; | |
| 610 | + | |
| 611 | + if ( in_array( $screen->id, $wml_screens, true ) ) { | |
| 612 | + $footer_text = sprintf( | |
| 613 | + /* translators: 1: WP Mail Log, 2: Link to plugin review */ | |
| 614 | + __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'wpv-wml' ), | |
| 615 | + '<strong>' . __( 'WP Mail Log', 'wpv-wml' ) . '</strong>', | |
| 616 | + '<a href="https://wordpress.org/support/plugin/wp-mail-log/reviews/#new-post" target="_blank">★★★★★</a>' | |
| 617 | + ); | |
| 618 | + } | |
| 619 | + | |
| 620 | + return $footer_text; | |
| 621 | + } | |
| 454 | 622 | |
| 455 | 623 | } |
| 456 | 624 | |
| 457 | 625 | WP_MAIL_LOG::get_instance(); |