@author Vova Feldman (@svovaf)
@since  1.0.5

@param bool $show_notice
347863
protected function _deactivate_license( $show_notice = true ) {
            $this->_logger->entrance();

            $hmm_text = $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...';

            if ( ! FS_Plugin_License::is_valid_id( $this->_site->license_id ) ) {
                $this->_admin_notices->add(
                    sprintf( $this->get_text_inline( 'It looks like your site currently doesn\'t have an active license.', 'no-active-license-message' ), $this->get_plan_title() ),
                    $hmm_text
                );

                return;
            }

            $api     = $this->get_api_site_scope();
            $license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );

            $this->handle_license_deactivation_result( $license, $hmm_text, $show_notice );
        }
1107093
public function renderUntil($field_name, $showFormEnd = true, $showFields = true)
    {
        $fields = $this->getUnrenderedFields();

        $i = 1;
        foreach ($fields as $key => $value) {
            if ($value->getRealName() == $field_name) {
                break;
            }
            $i++;
        }

        $fields = array_slice($fields, 0, $i, true);

        return $this->render([], $fields, false, $showFields, $showFormEnd);
    }
1339449
private function load_notices() {
        $notices = get_option( 'wp_easy_notify_' . $this->prefix, array() );
        $this->notices = $notices;

        $active = get_option( 'wp_easy_notify_active_' . $this->prefix, array() );
        $this->active = $active;
    }
811331
public function admin_notices() {
		if ( ! current_user_can( $this->userRole ) ) {
			return;
		}

		$prompt = $this->getNext();
		if ( empty( $prompt ) ) {
			return;
		}

		$slides = $this->getPromptSlides( $prompt );
		if ( ! empty( $slides ) ) {
			echo '<div class="notice notice-success bglib-rating-prompt is-dismissible" data-slide-name="' . esc_attr( $prompt['name'] ) . '">';
			foreach ( $slides as $slide ) {
				echo $slide;
			}
			wp_nonce_field( 'bglib-rating-prompt' );
			echo '</div>';
		}
	}
247158
public function showform( $id = null, $public_fields = null, $label = 'Save changes' ) {

		if ( Pod::$deprecated_notice ) {
			pods_deprecated( 'Pods::showform', '2.0' );
		}

		$public_columns =& $public_fields;

		$pod                     = $this->obj->pod;
		$pod_id                  = $this->obj->pod_id;
		$this->obj->type_counter = array();

		if ( ! empty( $public_fields ) ) {
			$attributes = array();

			foreach ( $public_fields as $key => $value ) {
				if ( is_array( $public_fields[ $key ] ) ) {
					$attributes[ $key ] = $value;
				} else {
					$attributes[ $value ] = array();
				}
			}
		}

		$fields = $this->obj->fields;

		// Re-order the fields if a public form
		if ( ! empty( $attributes ) ) {
			$fields = array();

			foreach ( $attributes as $key => $value ) {
				if ( isset( $this->obj->fields[ $key ] ) ) {
					$fields[ $key ] = $this->obj->fields[ $key ];
				}
			}
		}

		do_action( 'pods_showform_pre', $pod_id, $public_fields, $label, $this );

		foreach ( $fields as $key => $field ) {
			if ( ! is_array( $field ) || in_array( $key, array( 'created', 'modified' ), true ) ) {
				continue;
			}

			// Pass options so they can be manipulated via form
			$field = array_merge( $field['options'], $field );

			// Replace field attributes with public form attributes
			if ( ! empty( $attributes ) && is_array( $attributes[ $key ] ) ) {
				$field = array_merge( $field, $attributes[ $key ] );
			}

			// Replace the input helper name with the helper code
			if ( ! empty( $field['input_helper'] ) ) {
				$helper                = $this->obj->api->load_helper( array( 'name' => $field['input_helper'] ) );
				$field['input_helper'] = '';

				if ( ! empty( $helper ) ) {
					$field['input_helper'] = $helper['code'];
				}
			}

			if ( empty( $field['label'] ) ) {
				$field['label'] = ucwords( $key );
			}

			if ( 1 == $field['required'] ) {
				$field['label'] .= ' <span class="red">*</span>';
			}

			if ( ! empty( $field['pick_val'] ) ) {
				$selected_ids = array();
				$pick_object  = $field['pick_object'];
				$pick_val     = $field['pick_val'];

				if ( 'pod' === $pick_object ) {
					$pick_pod    = $this->obj->api->load_pod( array( 'name' => $pick_val ) );
					$pick_object = $pick_pod['type'];
					$pick_val    = $pick_pod['name'];
				}

				$pick_table = '';
				$pick_join  = '';
				$pick_where = '';

				$pick_field_id   = 'id';
				$pick_field_name = 'name';
				switch ( $pick_object ) {
					case 'pod':
						$pick_table      = "@wp_pods_{$pick_val}";
						$pick_field_id   = 'id';
						$pick_field_name = 'name';
						break;
					case 'post_type':
						$pick_table      = '@wp_posts';
						$pick_field_id   = 'ID';
						$pick_field_name = 'post_title';
						$pick_where      = "t.`post_type` = '{$pick_val}'";
						break;
					case 'taxonomy':
						$pick_table      = '@wp_terms';
						$pick_field_id   = 'term_id';
						$pick_field_name = 'name';
						$pick_join       = '`@wp_term_taxonomy` AS tx ON tx.`term_id` = t.`term_id';
						$pick_where      = "tx.`taxonomy` = '{$pick_val}' AND tx.`taxonomy` IS NOT NULL";
						break;
					case 'user':
						$pick_table      = '@wp_users';
						$pick_field_id   = 'ID';
						$pick_field_name = 'user_login';
						break;
					case 'comment':
						$pick_table      = '@wp_comments';
						$pick_field_id   = 'comment_ID';
						$pick_field_name = 'comment_date';
						$pick_where      = "t.`comment_type` = '{$pick_val}'";
						break;
					case 'table':
						$pick_table      = "{$pick_val}";
						$pick_field_id   = 'id';
						$pick_field_name = 'name';
						break;
				}//end switch

				$sql = 'SELECT `related_item_id` FROM `@wp_podsrel` WHERE `item_id` = %d AND `field_id` = %d';

				$sql = array( $sql, array( $id, $field['id'] ) );

				$result = pods_query( $sql, $this );

				foreach ( $result as $row ) {
					$selected_ids[] = $row->related_item_id;
				}

				// Use default values for public forms
				if ( empty( $selected_ids ) && ! empty( $field['default'] ) ) {
					$default_ids = $field['default'];

					if ( ! is_array( $field['default'] ) ) {
						$default_ids = explode( ',', $default_ids );
					}

					foreach ( $default_ids as $default_id ) {
						$default_id = pods_absint( $default_id );

						if ( 0 < $default_id ) {
							$selected_ids[] = $default_id;
						}
					}
				}

				// If the PICK field is unique, get values already chosen
				$exclude = false;

				if ( 1 == $field['unique'] ) {
					$unique_where = ( empty( $id ) ) ? '' : ' AND `item_id` != %d';

					$sql = "SELECT `related_item_id` FROM `@wp_podsrel` WHERE `field_id` = %d {$unique_where}";

					$sql = array( $sql, array( $field['id'] ) );

					if ( ! empty( $id ) ) {
						$sql[1][] = $id;
					}

					$result = pods_query( $sql, $this );

					if ( ! empty( $result ) ) {

						$exclude = array();

						foreach ( $result as $row ) {
							$exclude[] = (int) $row->related_item_id;
						}

						$exclude = implode( ',', $exclude );
					}
				}//end if

				if ( ! empty( $field['options']['pick_filter'] ) ) {
					$pick_where .= ' AND ' . $field['options']['pick_filter'];
				}

				$params = array(
					'exclude'      => $exclude,
					'selected_ids' => $selected_ids,
					'table'        => $pick_table,
					'field_id'     => $pick_field_id,
					'field_name'   => $pick_field_name,
					'join'         => $pick_join,
					'orderby'      => $field['options']['pick_orderby'],
					'where'        => $pick_where,
				);

				$this->obj->row[ $key ] = $this->get_dropdown_values( $params );
			} else {
				// Set a default value if no value is entered
				if ( ! isset( $this->obj->row[ $key ] ) || ( null === $this->obj->row[ $key ] || false === $this->obj->row[ $key ] ) ) {
					if ( ! empty( $field['default'] ) ) {
						$this->obj->row[ $key ] = $field['default'];
					} else {
						$this->obj->row[ $key ] = null;
					}
				}
			}//end if

			$this->obj->build_field_html( $field );
		}//end foreach

		$uri_hash = wp_hash( $_SERVER['REQUEST_URI'] );

		$save_button_atts = array(
			'type'    => 'button',
			'class'   => 'button btn_save',
			'value'   => $label,
			'onclick' => 'saveForm(1)',
		);

		$save_button_atts = apply_filters( 'pods_showform_save_button_atts', $save_button_atts, $this );
		$atts             = '';

		foreach ( $save_button_atts as $att => $value ) {
			$atts .= ' ' . esc_attr( $att ) . '="' . esc_attr( $value ) . '"';
		}

		$save_button = '<input ' . $atts . '/>';
		?>
		<div>
			<input type="hidden" class="form num id" value="<?php echo esc_attr( $id ); ?>" />
			<input type="hidden" class="form txt pod" value="<?php echo esc_attr( $pod ); ?>" />
			<input type="hidden" class="form txt pod_id" value="<?php echo esc_attr( $pod_id ); ?>" />
			<input type="hidden" class="form txt form_count" value="1" />
			<input type="hidden" class="form txt token" value="<?php echo esc_attr( pods_generate_key( $pod, $uri_hash, $public_fields, 1 ) ); ?>" />
			<input type="hidden" class="form txt uri_hash" value="<?php echo esc_attr( $uri_hash ); ?>" />
			<?php echo apply_filters( 'pods_showform_save_button', $save_button, $save_button_atts, $this ); ?>
		</div>
		<?php
		do_action( 'pods_showform_post', $pod_id, $public_fields, $label, $this );
	}
1131193
public function notice(callable $callback)
    {
        $this->registerError(E_DEPRECATED, $callback);
        $this->registerError(E_USER_DEPRECATED, $callback);
        $this->registerError(E_NOTICE, $callback);
        $this->registerError(E_USER_NOTICE, $callback);
    }
27789
public static function show_notification() {

		$current_notification = self::get_last_notification();

		$notification_details = [];
		// Check if the saved notification is still present among the possible ones.
		if ( ! empty( $current_notification ) ) {
			$notification_details = self::get_notification_details( $current_notification );
			if ( empty( $notification_details ) ) {
				$current_notification = [];
			}
		}
		// Check if the notificatin is expired.
		if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) {
			update_option( $current_notification['id'], 'no' );
			self::set_last_active_notification_timestamp();
			$current_notification = [];
		}
		// If we don't have any saved notification, get a new one.
		if ( empty( $current_notification ) ) {
			$notification_details = self::get_random_notification();
			if ( empty( $notification_details ) ) {
				return;
			}
			self::set_active_notification(
				[
					'id'         => $notification_details['id'],
					'display_at' => time(),
				]
			);
		}
		if ( empty( $notification_details ) ) {
			return;
		}
		$notification_html = self::get_notification_html( $notification_details );
		do_action( $notification_details['id'] . '_before_render' );

		echo $notification_html;

		do_action( $notification_details['id'] . '_after_render' );
		self::render_snippets();
	}
688414
public function setShowFeedback($showFeedback)
    {
        if (is_bool($showFeedback)) {
            $this->showFeedback = $showFeedback;
        } else {
            $msg = "ShowFeedback must be a boolean, '" . gettype($showFeedback) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
363745
function _add_affiliate_program_notice() {
            if ( ! $this->is_user_admin() ) {
                return false;
            }

            if ( ! $this->is_user_in_admin() ) {
                return false;
            }

            // Check if the notice is already shown.
            if ( $this->_admin_notices->has_sticky( 'affiliate_program' ) ) {
                return false;
            }

            if (
                // Product has no affiliate program.
                ! $this->has_affiliate_program() ||
                // User has applied for an affiliate account.
                ! empty( $this->_storage->affiliate_application_data )
            ) {
                return false;
            }

            if ( ! $this->apply_filters( 'show_affiliate_program_notice', true ) ) {
                // Developer explicitly asked not to show the notice about the affiliate program.
                return false;
            }

            if ( $this->is_activation_mode() || $this->is_pending_activation() ) {
                // If not yet opted in/skipped, or pending activation, don't show the notice.
                return false;
            }

            $last_time_notice_was_shown = $this->_storage->get( 'affiliate_program_notice_shown', false );
            $was_notice_shown_before    = ( false !== $last_time_notice_was_shown );

            /**
             * Do not show the notice if it was already shown before or less than 30 days have passed since the initial
             * activation with FS.
             */
            if ( $was_notice_shown_before ||
                 $this->_storage->install_timestamp > ( time() - ( WP_FS__TIME_24_HOURS_IN_SEC * 30 ) )
            ) {
                return false;
            }

            if ( ! $this->is_paying() &&
                 FS_Plugin::AFFILIATE_MODERATION_CUSTOMERS == $this->_plugin->affiliate_moderation
            ) {
                // If the user is not a customer and the affiliate program is only for customers, don't show the notice.
                return false;
            }

            $message = sprintf(
                $this->get_text_inline( 'Hey there, did you know that %s has an affiliate program? If you like the %s you can become our ambassador and earn some cash!', 'become-an-ambassador-admin-notice' ),
                sprintf( '<strong>%s</strong>', $this->get_plugin_name() ),
                $this->get_module_label( true )
            );

            // HTML code for the "Learn more..." button.
            $button = ' ' . sprintf(
                    '<a style="display: block; margin-top: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
                    $this->_get_admin_page_url( 'affiliation' ),
                    $this->get_text_inline( 'Learn more', 'learn-more' ) . '...'
                );

            $this->_admin_notices->add_sticky(
                $this->apply_filters( 'affiliate_program_notice', "{$message} {$button}" ),
                'affiliate_program',
                '',
                'promotion'
            );

            $this->_storage->affiliate_program_notice_shown = WP_FS__SCRIPT_START_TIME;

            return true;
        }
1064323
function _add_trial_notice() {
            if ( ! $this->is_user_admin() ) {
                return false;
            }

            if ( ! $this->is_user_in_admin() ) {
                return false;
            }

            if ( $this->_is_network_active ) {
                if ( fs_is_network_admin() ) {
                    // Network level trial is disabled at the moment.
                    return false;
                }

                if ( ! $this->is_delegated_connection() ) {
                    // Only delegated sites should support trials.
                    return false;
                }
            }

            // Check if trial message is already shown.
            if ( $this->is_in_trial_promotion() ) {
                add_action( 'admin_footer', array( &$this, '_fix_start_trial_menu_item_url' ) );

                $this->_menu->add_counter_to_menu_item( 1, 'fs-trial' );

                return false;
            }

            if ( $this->is_premium() && ! WP_FS__DEV_MODE ) {
                // Don't show trial if running the premium code, unless running in DEV mode.
                return false;
            }

            if ( ! $this->has_trial_plan() ) {
                // No plans with trial.
                return false;
            }

            if ( ! $this->apply_filters( 'show_trial', true ) ) {
                // Developer explicitly asked not to show the trial promo.
                return false;
            }

            if ( $this->is_registered() ) {
                // Check if trial already utilized.
                if ( $this->_site->is_trial_utilized() ) {
                    return false;
                }

                if ( $this->is_paying_or_trial() ) {
                    // Don't show trial if paying or already in trial.
                    return false;
                }
            }

            if ( $this->is_activation_mode() || $this->is_pending_activation() ) {
                // If not yet opted-in/skipped, or pending activation, don't show trial.
                return false;
            }

            $last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
            $was_promotion_shown_before      = ( false !== $last_time_trial_promotion_shown );

            // Show promotion if never shown before and 24 hours after initial activation with FS.
            if ( ! $was_promotion_shown_before &&
                 $this->_storage->install_timestamp > ( time() - $this->apply_filters( 'show_first_trial_after_n_sec', WP_FS__TIME_24_HOURS_IN_SEC ) )
            ) {
                return false;
            }

            // OR if promotion was shown before, try showing it every 30 days.
            if ( $was_promotion_shown_before &&
                 $this->apply_filters( 'reshow_trial_after_every_n_sec', 30 * WP_FS__TIME_24_HOURS_IN_SEC ) > time() - $last_time_trial_promotion_shown
            ) {
                return false;
            }

            $trial_period    = $this->_trial_days;
            $require_payment = $this->_is_trial_require_payment;
            $trial_url       = $this->get_trial_url();
            $plans_string    = strtolower( $this->get_text_inline( 'Awesome', 'awesome' ) );

            if ( $this->is_registered() ) {
                // If opted-in, override trial with up to date data from API.
                $trial_plans       = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
                $trial_plans_count = count( $trial_plans );

                if ( 0 === $trial_plans_count ) {
                    // If there's no plans with a trial just exit.
                    return false;
                }

                /**
                 * @var FS_Plugin_Plan $paid_plan
                 */
                $paid_plan       = $trial_plans[0];
                $require_payment = $paid_plan->is_require_subscription;
                $trial_period    = $paid_plan->trial_period;

                $total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );

                if ( $total_paid_plans !== $trial_plans_count ) {
                    // Not all paid plans have a trial - generate a string of those that have it.
                    for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
                        $plans_string .= sprintf(
                            ' <a href="%s">%s</a>',
                            $trial_url,
                            $trial_plans[ $i ]->title
                        );

                        if ( $i < $trial_plans_count - 2 ) {
                            $plans_string .= ', ';
                        } else if ( $i == $trial_plans_count - 2 ) {
                            $plans_string .= ' and ';
                        }
                    }
                }
            }

            $message = sprintf(
                $this->get_text_x_inline( 'Hey', 'exclamation', 'hey' ) . '! ' . $this->get_text_inline( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.', 'trial-x-promotion-message' ),
                sprintf( '<b>%s</b>', $this->get_plugin_name() ),
                $plans_string,
                $trial_period
            );

            // "No Credit-Card Required" or "No Commitment for N Days".
            $cc_string = $require_payment ?
                sprintf( $this->get_text_inline( 'No commitment for %s days - cancel anytime!', 'no-commitment-for-x-days' ), $trial_period ) :
                $this->get_text_inline( 'No credit card required', 'no-cc-required' ) . '!';


            // Start trial button.
            $button = ' ' . sprintf(
                    '<a style="margin-left: 10px; vertical-align: super;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
                    $trial_url,
                    $this->get_text_x_inline( 'Start free trial', 'call to action', 'start-free-trial' )
                );

            $this->_admin_notices->add_sticky(
                $this->apply_filters( 'trial_promotion_message', "{$message} {$cc_string} {$button}" ),
                'trial_promotion',
                '',
                'promotion'
            );

            $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;

            return true;
        }
777172
public function showDescription()
    {
        if ($this->showDescription === null) {
            $prop = $this->property();
            $show = $prop['show_description'];
            if ($show !== null) {
                $this->showDescription = $show;
            } else {
                $this->showDescription = true;
            }
        }

        if ($this->showDescription !== false) {
            return !!strval($this->property()->description());
        } else {
            return false;
        }
    }
1291380
public static function endshow($val, $showHeader = true, HTTPRequest $request = null)
    {
        // Don't show on live
        if (Director::isLive()) {
            return;
        }

        echo static::create_debug_view($request)
            ->debugVariable($val, static::caller(), $showHeader);

        die();
    }
380078
public function show_401_error_message() {
		$_401       = false;
		$error_code = $this->get_error_codes();
		foreach ( (array) $error_code as $repo ) {
			if ( ( ! $_401 && isset( $repo['code'] ) ) && 401 === $repo['code'] ) {
				$_401 = true;
				if ( ! \PAnD::is_admin_notice_active( '401-error-1' ) ) {
					return;
				}
				?>
				<div data-dismissible="401-error-1" class="notice-error notice is-dismissible">
					<p>
						<?php
						esc_html_e( 'GitHub Updater Error Code:', 'github-updater' );
						echo ' ' . $repo['code'];
						?>
						<br>
						<?php esc_html_e( 'There is probably an access token or password error on the GitHub Updater Settings page.', 'github-updater' ); ?>
					</p>
				</div>
				<?php
			}
		}
	}
160677
private function get_site_notices( $blog_id = 0 ) {
            if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
                return $this->_notices;
            }

            return FS_Admin_Notice_Manager::instance(
                $this->_id,
                $this->_title,
                $this->_module_unique_affix,
                false,
                $blog_id
            );
        }
589696
public function action_admin_notices() {
		$user     = wp_get_current_user();
		$old_user = self::get_old_user();

		if ( $old_user ) {
			?>
			<div id="user_switching" class="updated notice is-dismissible">
				<p><span class="dashicons dashicons-admin-users" style="color:#56c234" aria-hidden="true"></span>
				<?php
					$message       = '';
					$just_switched = isset( $_GET['user_switched'] );
					if ( $just_switched ) {
						$message = esc_html( sprintf(
							/* Translators: 1: user display name; 2: username; */
							__( 'Switched to %1$s (%2$s).', 'user-switching' ),
							$user->display_name,
							$user->user_login
						) );
					}
					$switch_back_url = add_query_arg( array(
						'redirect_to' => urlencode( self::current_url() ),
					), self::switch_back_url( $old_user ) );

					$message .= sprintf(
						' <a href="%s">%s</a>.',
						esc_url( $switch_back_url ),
						esc_html( sprintf(
							/* Translators: 1: user display name; 2: username; */
							__( 'Switch back to %1$s (%2$s)', 'user-switching' ),
							$old_user->display_name,
							$old_user->user_login
						) )
					);

					/**
					 * Filters the contents of the message that's displayed to switched users in the admin area.
					 *
					 * @since 1.1.0
					 *
					 * @param string  $message         The message displayed to the switched user.
					 * @param WP_User $user            The current user object.
					 * @param WP_User $old_user        The old user object.
					 * @param string  $switch_back_url The switch back URL.
					 * @param bool    $just_switched   Whether the user made the switch on this page request.
					 */
					$message = apply_filters( 'user_switching_switched_message', $message, $user, $old_user, $switch_back_url, $just_switched );
					// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
					echo $message;
				?>
				</p>
			</div>
			<?php
		} elseif ( isset( $_GET['user_switched'] ) ) {
			?>
			<div id="user_switching" class="updated notice is-dismissible">
				<p>
				<?php
					if ( isset( $_GET['switched_back'] ) ) {
						echo esc_html( sprintf(
							/* Translators: 1: user display name; 2: username; */
							__( 'Switched back to %1$s (%2$s).', 'user-switching' ),
							$user->display_name,
							$user->user_login
						) );
					} else {
						echo esc_html( sprintf(
							/* Translators: 1: user display name; 2: username; */
							__( 'Switched to %1$s (%2$s).', 'user-switching' ),
							$user->display_name,
							$user->user_login
						) );
					}
				?>
				</p>
			</div>
			<?php
		}
	}
806584
public static function notice(...$messages): void
    {
        static::init();

        if (!static::isTemporaryDisabled('notice')) {
            foreach (static::$adapters as $adapter) {
                /* @var $adapter \Koldy\Log\Adapter\AbstractLogAdapter */
                if ($adapter->isLevelEnabled(self::NOTICE)) {
                    $adapter->notice((new Message(self::NOTICE))->setMessages($messages));
                }
            }
        }
    }
1179048
public static final function notice( $text, $close = false ) {
		$callback = function () use ( &$text, &$close ) {
			$close = ( $close ) ? ' notice is-dismissible' : '';
			self::nt( $text );
		};
		Action::adminNotices( $callback );
	}