settings->get_option( 'headers_footers_mode' ) ) { return; } // If this is a multisite and the user is a super admin let's see if they already dismissed this on other sites. if ( is_multisite() && is_super_admin() ) { $dismissed = get_user_meta( get_current_user_id(), 'wpcode_dismissed_review_request', true ); if ( ! empty( $dismissed ) ) { return; } } // Verify that we can do a check for reviews. $notices = get_option( 'wpcode_admin_notices', array() ); $time = time(); $load = false; if ( empty( $notices['review_request'] ) ) { $notices['review_request'] = array( 'time' => $time, 'dismissed' => false, ); update_option( 'wpcode_admin_notices', $notices ); return; } // Check if it has been dismissed or not. if ( ( isset( $notices['review_request']['dismissed'] ) && ! $notices['review_request']['dismissed'] ) && ( isset( $notices['review_request']['time'] ) && ( ( $notices['review_request']['time'] + DAY_IN_SECONDS ) <= $time ) ) ) { $load = true; } // If we cannot load, return early. if ( ! $load ) { return; } $this->review(); } /** * Maybe show Lite review request. */ public function review() { // Fetch when plugin was initially installed. $activated = get_option( 'ihaf_activated', array() ); if ( ! empty( $activated['wpcode'] ) ) { // Only continue if plugin has been installed for at least 14 days. if ( ( $activated['wpcode'] + ( DAY_IN_SECONDS * 14 ) ) > time() ) { return; } } else { $activated['wpcode'] = time(); update_option( 'ihaf_activated', $activated ); return; } // Only proceed with displaying if the user is using an active snippet. $snippet_count = wp_count_posts( 'wpcode' ); if ( empty( $snippet_count->publish ) ) { return; } $feedback_url = add_query_arg( array( 'siteurl' => untrailingslashit( home_url() ), 'plugin' => class_exists( 'WPCode_Premium') ? 'pro' : 'lite', 'version' => WPCODE_VERSION, ), 'https://www.wpcode.com/plugin-feedback/' ); $feedback_url = wpcode_utm_url( $feedback_url, 'review-notice', 'feedback' ); ob_start(); // We have a candidate! Output a review message. ?>
WPCode_Notice::DISMISS_GLOBAL, 'slug' => 'review_request', 'autop' => false, 'class' => 'wpcode-review-notice', ) ); } /** * When user is on a WPCode related admin page, display footer text * that graciously asks them to rate us. * * @param string $text Footer text. * * @return string * * */ public function admin_footer( $text ) { global $current_screen; if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'wpcode' ) !== false ) { $url = 'https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/?filter=5#new-post'; $text = sprintf( wp_kses( /* translators: $1$s - WPCode plugin name; $2$s - WP.org review link; $3$s - WP.org review link. */ __( 'Please rate %1$s ★★★★★ on WordPress.org to help us spread the word. Thank you from the WPCode team!', 'insert-headers-and-footers' ), array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array(), ), ) ), 'WPCode', $url, $url ); } return $text; } } new WPCode_Review();