AnsPress_Notification_Query::get_verb()

Description #

Get the verb of a notification.

Source #

File: addons/free/notification/query.php

	public function get_verb() {
		$key = $this->object->noti_verb;
		$verb_text = '';

		if ( isset( $this->verbs[ $key ] ) ) {
			$args = $this->verbs[ $key ];
			$verb_text = $args['label'];

			$args = array(
				'%cpt%' => __( 'post', 'anspress-question-answer' ),
				'%points%' => number_format_i18n( 0 ),
			);

			if ( isset( $this->object->ref ) ) {
				if ( isset( $this->object->ref->post_type ) ) {
					if ( 'question' === $this->object->ref->post_type ) {
						$args['%cpt%'] = __( 'question', 'anspress-question-answer' );
					} elseif ( 'answer' === $this->object->ref->post_type ) {
						$args['%cpt%'] = __( 'answer', 'anspress-question-answer' );
					}
				}

				if ( isset( $this->object->ref->points ) ) {
					$args['%points%'] = number_format_i18n( $this->object->ref->points );
				}
			}

			$verb_text = strtr( $verb_text, $args );
		}

		return $verb_text;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment