PHP code example of yahnis-elsts / plugin-update-checker

1. Go to this page and download the library: Download yahnis-elsts/plugin-update-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yahnis-elsts / plugin-update-checker example snippets


		use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
 
	$myUpdateChecker = PucFactory::buildUpdateChecker(
		'https://example.com/path/to/details.json',
		__FILE__, //Full path to the main plugin file or functions.php.
		'unique-plugin-or-theme-slug'
	);
	

		use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
 
	$myUpdateChecker = PucFactory::buildUpdateChecker(
		'https://github.com/user-name/repo-name/',
		__FILE__,
		'unique-plugin-or-theme-slug'
	);
	
	//Set the branch that contains the stable release.
	$myUpdateChecker->setBranch('stable-branch-name');

	//Optional: If you're using a private repository, specify the access token like this:
	$myUpdateChecker->setAuthentication('your-token-here');
	

	$myUpdateChecker->getVcsApi()->enableReleaseAssets();
	

	 $updateChecker->setBranch('branch-name');
	 

		use YahnisElsts\PluginUpdateChecker\v5\PucFactory;
 
	$myUpdateChecker = PucFactory::buildUpdateChecker(
		'https://bitbucket.org/user-name/repo-name',
		__FILE__,
		'unique-plugin-or-theme-slug'
	);

	//Optional: If you're using a private repository, create an OAuth consumer
	//and set the authentication credentials like this:
	//Note: For now you need to check "This is a private consumer" when
	//creating the consumer to work around #134:
	// https://github.com/YahnisElsts/plugin-update-checker/issues/134
	$myUpdateChecker->setAuthentication(array(
		'consumer_key' => '...',
		'consumer_secret' => '...',
	));

	//Optional: Set the branch that contains the stable release.
	$myUpdateChecker->setBranch('stable-branch-name');
	

	 $updateChecker->setBranch('branch-name');
	 

		use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

	$myUpdateChecker = PucFactory::buildUpdateChecker(
		'https://gitlab.com/user-name/repo-name/',
		__FILE__,
		'unique-plugin-or-theme-slug'
	);

	//Optional: If you're using a private repository, specify the access token like this:
	$myUpdateChecker->setAuthentication('your-token-here');
	

	use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker;
	use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitLabApi;
	
	$myUpdateChecker = new PluginUpdateChecker(
		new GitLabApi('https://myserver.com/user-name/repo-name/'),
		__FILE__,
		'unique-plugin-or-theme-slug'
	);
	//Optional: Add setAuthentication(...) and setBranch(...) as shown above.  
	

	use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker;
	use YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitLabApi;
   
	$myUpdateChecker = new PluginUpdateChecker(
		new GitLabApi(
			'https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', 
			null, 
			'subgroup-level1/subgroup-level2/subgroup-level3'
		),
		__FILE__,
		'unique-plugin-or-theme-slug'
	);
	

	$myUpdateChecker->getVcsApi()->enableReleaseAssets();
	

	$myUpdateChecker->getVcsApi()->enableReleaseAssets('/\.zip($|[?&#])/i');
	

	$myUpdateChecker->setBranch('stable-branch-name');
	

$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
	'https://example.com/info.json',
	__FILE__,
	'my-slug'
);

use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

$myUpdateChecker = PucFactory::buildUpdateChecker(
	'https://example.com/info.json',
	__FILE__,
	'my-slug'
);