$choice ) ); } /** * Published terms in all set-up glossaries (filtered through azgl_thanks_count). * * @return int */ public static function count() { $options = get_option( 'azgl_options', array() ); $count = 0; if ( is_array( $options ) && ! empty( $options['glossaries'] ) && is_array( $options['glossaries'] ) ) { foreach ( $options['glossaries'] as $glossary ) { if ( is_array( $glossary ) && ! empty( $glossary['page_id'] ) ) { $count += azgl()->get_entry_count( absint( $glossary['page_id'] ) ); } } } /** * Number of published terms the thank-you card refers to. * * @param int $count Published terms. */ return (int) apply_filters( 'azgl_thanks_count', $count ); } /** * Card for one tab of the plugin page, or an empty string. * * @param string $tab Current tab. * @return string */ public static function card( $tab ) { if ( ! in_array( $tab, self::TABS, true ) || ! current_user_can( 'manage_options' ) ) { return ''; } $installed = (int) get_option( self::INSTALLED, 0 ); if ( $installed < 1 ) { update_option( self::INSTALLED, time(), false ); return ''; } if ( time() - $installed < self::WAIT_DAYS * DAY_IN_SECONDS ) { return ''; } $state = self::state( get_current_user_id() ); if ( in_array( $state['state'], array( 'done', 'never' ), true ) || $state['asked'] >= self::MAX_ASKS || ( 'later' === $state['state'] && time() < $state['until'] ) ) { return ''; } $count = self::count(); if ( $count < self::MIN_TERMS ) { return ''; } $html = '
'; $html .= ''; /* translators: %d: number of published glossary terms. */ $html .= '

' . esc_html( sprintf( _n( 'Your readers find %d term explained. Thank you for using 3task Glossary.', 'Your readers find %d terms explained. Thank you for using 3task Glossary.', $count, '3task-glossary' ), $count ) ) . '

'; $html .= '

' . esc_html__( 'You know how much work goes into explaining a term clearly. A short, honest review is a small explanation too: it helps the next site owner decide.', '3task-glossary' ) . '

'; $html .= '

' . esc_html__( 'I am Frank, and I build 3task Glossary myself, without ads and without tracking. Nobody has to pay for it. What keeps it going is hearing from the people who use it.', '3task-glossary' ) . '

'; $html .= '

' . esc_html__( 'Would you leave a short review on WordPress.org? One honest sentence is enough, good or critical. If something is missing, tell me in the support forum and I will look at it.', '3task-glossary' ) . '

'; $html .= '

'; $html .= '' . esc_html__( 'Write a review on WordPress.org', '3task-glossary' ) . ' '; $html .= '' . esc_html__( 'Something is missing? Tell me', '3task-glossary' ) . ' '; $html .= ' '; $html .= ''; $html .= '

' . esc_html__( 'This note appears at most twice and only on the Dashboard and Glossaries tabs of 3task Glossary. Nothing changes in the plugin, whatever you choose.', '3task-glossary' ) . '

'; return $html; } /** * Stored choice of one user. * * @param int $user_id User ID. * @return array{state:string, until:int, asked:int} */ private static function state( $user_id ) { $raw = get_user_meta( (int) $user_id, self::META, true ); $raw = is_array( $raw ) ? $raw : array(); return array( 'state' => isset( $raw['state'] ) && in_array( $raw['state'], array( 'done', 'later', 'never' ), true ) ? $raw['state'] : '', 'until' => isset( $raw['until'] ) ? (int) $raw['until'] : 0, 'asked' => isset( $raw['asked'] ) ? max( 0, (int) $raw['asked'] ) : 0, ); } }