slug = $args['slug']; $this->name = $args['name']; $this->date_option = $this->slug . '_activation_date'; $this->nobug_option = $this->slug . '_no_bug'; if ( isset( $args['time_limit'] ) ) { $this->time_limit = $args['time_limit']; } else { $this->time_limit = WEEK_IN_SECONDS; } // Add actions. add_action( 'admin_init', array( $this, 'check_installation_date' ) ); add_action( 'admin_init', array( $this, 'set_no_bug' ), 5 ); } /** * Seconds to words. * * @access public * @param string $seconds Seconds in time. */ public function seconds_to_words( $seconds ) { // Get the years. $years = ( intval( $seconds ) / YEAR_IN_SECONDS ) % 100; if ( $years > 1 ) { /* translators: Number of years */ return sprintf( __( '%s years', 'alnp-facebook-pixel-tracking' ), $years ); } elseif ( $years > 0 ) { return __( 'a year', 'alnp-facebook-pixel-tracking' ); } // Get the weeks. $weeks = ( intval( $seconds ) / WEEK_IN_SECONDS ) % 52; if ( $weeks > 1 ) { /* translators: Number of weeks */ return sprintf( __( '%s weeks', 'alnp-facebook-pixel-tracking' ), $weeks ); } elseif ( $weeks > 0 ) { return __( 'a week', 'alnp-facebook-pixel-tracking' ); } // Get the days. $days = ( intval( $seconds ) / DAY_IN_SECONDS ) % 7; if ( $days > 1 ) { /* translators: Number of days */ return sprintf( __( '%s days', 'alnp-facebook-pixel-tracking' ), $days ); } elseif ( $days > 0 ) { return __( 'a day', 'alnp-facebook-pixel-tracking' ); } // Get the hours. $hours = ( intval( $seconds ) / HOUR_IN_SECONDS ) % 24; if ( $hours > 1 ) { /* translators: Number of hours */ return sprintf( __( '%s hours', 'alnp-facebook-pixel-tracking' ), $hours ); } elseif ( $hours > 0 ) { return __( 'an hour', 'alnp-facebook-pixel-tracking' ); } // Get the minutes. $minutes = ( intval( $seconds ) / MINUTE_IN_SECONDS ) % 60; if ( $minutes > 1 ) { /* translators: Number of minutes */ return sprintf( __( '%s minutes', 'alnp-facebook-pixel-tracking' ), $minutes ); } elseif ( $minutes > 0 ) { return __( 'a minute', 'alnp-facebook-pixel-tracking' ); } // Get the seconds. $seconds = intval( $seconds ) % 60; if ( $seconds > 1 ) { /* translators: Number of seconds */ return sprintf( __( '%s seconds', 'alnp-facebook-pixel-tracking' ), $seconds ); } elseif ( $seconds > 0 ) { return __( 'a second', 'alnp-facebook-pixel-tracking' ); } } /** * Check date on admin initiation and add to admin notice if it was more than the time limit. * * @access public */ public function check_installation_date() { if ( ! get_site_option( $this->nobug_option ) || false === get_site_option( $this->nobug_option ) ) { add_site_option( $this->date_option, time() ); // Retrieve the activation date. $install_date = get_site_option( $this->date_option ); // If difference between install date and now is greater than time limit, then display notice. if ( ( time() - $install_date ) > $this->time_limit ) { add_action( 'admin_notices', array( $this, 'display_admin_notice' ) ); } } } /** * Display the admin notice. * * @access public */ public function display_admin_notice() { $screen = get_current_screen(); if ( isset( $screen->base ) && 'plugins' === $screen->base ) { $no_bug_url = wp_nonce_url( admin_url( '?' . $this->nobug_option . '=true' ), 'alnp-feedback-nounce' ); $time = $this->seconds_to_words( time() - get_site_option( $this->date_option ) ); ?>
<?php printf( esc_attr__( '%1$s WordPress Plugin', 'alnp-facebook-pixel-tracking' ), esc_attr( $this->name ) ); ?>

name ) ); ?>

name ), esc_html( $time ) ); ?>

%2$s', esc_url( ALNP_FB_PIXEL_REVIEW_URL . '#new-post' ), esc_html__( 'Leave a Review', 'alnp-facebook-pixel-tracking' ) ); ?>
nobug_option ] ) || ! current_user_can( 'manage_options' ) ) ) { return; } add_site_option( $this->nobug_option, true ); } } } /* * Instantiate the ALNP_FB_Pixel_Tracking_Feedback class. */ new ALNP_FB_Pixel_Tracking_Feedback( array( 'slug' => 'alnp_fbpixel_plugin_feedback', 'name' => __( 'Facebook Pixel Tracking for Auto Load Next Post', 'alnp-facebook-pixel-tracking' ), 'time_limit' => WEEK_IN_SECONDS, ) );