LLMS_Helper_Upgrader::pre_set_site_transient_update_things( obj $value )

Handle setting the site transient for plugin updates


Parameters Parameters

$value

(obj) (Required) Transient value.


Top ↑

Return Return

(obj)


Top ↑

Source Source

File: libraries/lifterlms-helper/includes/class-llms-helper-upgrader.php

	public function pre_set_site_transient_update_things( $value ) {

		if ( empty( $value ) ) {
			return $value;
		}

		$which = current_filter();
		if ( 'pre_set_site_transient_update_plugins' === $which ) {
			$type = 'plugin';
		} elseif ( 'pre_set_site_transient_update_themes' === $which ) {
			$type = 'theme';
		} else {
			return $value;
		}

		$all_products = llms_get_add_ons( false );
		if ( is_wp_error( $all_products ) || ! isset( $all_products['items'] ) ) {
			return $value;
		}

		foreach ( $all_products['items'] as $addon_data ) {

			$addon = llms_get_add_on( $addon_data );

			if ( ! $addon->is_installable() || ! $addon->is_installed() ) {
				continue;
			}

			if ( $type !== $addon->get_type() ) {
				continue;
			}

			$file = $addon->get( 'update_file' );

			if ( 'plugin' === $type ) {

				if ( 'lifterlms-com-lifterlms' === $addon->get( 'id' ) ) {
					if ( 'stable' === $addon->get_channel_subscription() || ! $addon->get( 'version_beta' ) ) {
						continue;
					}
				}

				$item = (object) $this->set_plugins_api( $addon->get( 'id' ), false );

			} elseif ( 'theme' === $type ) {

				$item = array(
					'theme'       => $file,
					'new_version' => $addon->get_latest_version(),
					'url'         => $addon->get_permalink(),
					'package'     => true,
				);
			}

			if ( $addon->has_available_update() ) {

				$value->response[ $file ] = $item;
				unset( $value->no_update[ $file ] );

			} else {

				$value->no_update[ $file ] = $item;
				unset( $value->response[ $file ] );

			}
		}

		return $value;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.2 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.