14 if ( ! defined(
'ABSPATH' ) ) {
54 'disapproved' => array(
55 'value' => self::DISAPPROVED,
56 'label' => esc_html__(
'Disapproved',
'gk-gravityview' ),
57 'action' => esc_html__(
'Disapprove',
'gk-gravityview' ),
58 'title' => esc_html__(
'Entry not approved for directory viewing. Click to approve this entry.',
'gk-gravityview' ),
61 'value' => self::APPROVED,
62 'label' => esc_html__(
'Approved',
'gk-gravityview' ),
63 'action' => esc_html__(
'Approve',
'gk-gravityview' ),
64 'title' => esc_html__(
'Entry approved for directory viewing. Click to disapprove this entry.',
'gk-gravityview' ),
65 'title_popover' => esc_html__(
'Entry approved for directory viewing. Click to disapprove this entry.',
'gk-gravityview' ),
67 'unapproved' => array(
68 'value' => self::UNAPPROVED,
69 'label' => esc_html__(
'Unapproved',
'gk-gravityview' ),
70 'action' => esc_html__(
'Reset Approval',
'gk-gravityview' ),
71 'title' => esc_html__(
'Entry not yet reviewed. Click to approve this entry.',
'gk-gravityview' ),
84 return self::get_choices();
96 $choices = self::get_choices();
98 $values = wp_list_pluck( $choices,
'value' );
114 $new_value = $old_value;
117 if(
false === $old_value ) {
118 return self::UNAPPROVED;
122 if(
true === $old_value ) {
123 return self::APPROVED;
126 switch ( (
string) $old_value ) {
131 $new_value = self::APPROVED;
137 $new_value = self::DISAPPROVED;
143 $new_value = self::UNAPPROVED;
167 return in_array(
$value, self::get_values(),
true );
179 $status = self::maybe_convert_status( $status );
181 return ( self::APPROVED === $status );
193 $status = self::maybe_convert_status( $status );
195 return ( self::DISAPPROVED === $status );
207 $status = self::maybe_convert_status( $status );
209 return ( self::UNAPPROVED === $status );
221 $choices = self::get_choices();
223 $labels = wp_list_pluck( $choices,
'label' );
247 $choices = self::get_choices();
249 foreach ( $choices as $key => $choice ) {
252 if ( $status === $choice[
'value'] || $status === $key ) {
253 if(
'key' === $attr_key ) {
256 return \GV\Utils::get( $choice, $attr_key,
false );
274 return self::choice_pluck( $value_or_key,
'label' );
287 return self::choice_pluck( $value_or_key,
'action' );
299 public static function get_string( $value_or_key, $string_key =
'' ) {
300 return self::choice_pluck( $value_or_key, $string_key );
313 return self::choice_pluck( $value_or_key,
'title' );
324 return self::choice_pluck(
$value,
'key' );
If this file is called directly, abort.
static get_values()
Get the status values as an array.
static get_choices()
Match values to the labels.
static get_labels()
Get the labels for the status choices.
static choice_pluck( $status, $attr_key='')
Pluck a certain field value from a status array.
static get_action( $value_or_key)
Get the label for a specific approval value.
static get_key( $value)
Get the status key for a value.
static get_title_attr( $value_or_key)
Get the label for a specific approval value.
static is_valid( $value=NULL)
Check whether the passed value is one of the defined values for entry approval.
static maybe_convert_status( $old_value='')
Convert previously-used values to the current values, for backward compatibility. ...
static get_string( $value_or_key, $string_key='')
Get the label for a specific approval value.
static is_disapproved( $status)
__construct()
GravityView_Entry_Approval_Status constructor.
static get_all()
Return array of status options.
static is_approved( $status)
static is_unapproved( $status)
static get_label( $value_or_key)
Get the label for a specific approval value.