PHP code example of wp-media / wp-imagify-partner

1. Go to this page and download the library: Download wp-media/wp-imagify-partner 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/ */

    

wp-media / wp-imagify-partner example snippets


define( 'EXAMPLE_IMAGIFY_PARTNER_ID' , 'test' );

add_action( 'plugins_loaded', 'example_plugin_init' );
/**
 * Init.
 */
function example_plugin_init() {
	if ( ! is_admin() ) {
		return;
	}

	nit();

	add_action( 'admin_menu', 'example_plugin_menu' );
}

/**
 * Add a submenu.
 */
function example_plugin_menu() {
	add_submenu_page( 'options-general.php', 'Example Plugin', 'Example Plugin', 'install_plugins', 'example-plugin', 'example_plugin_page' );
}

/**
 * The plugin page displaying a link to install Imagify plugin.
 */
function example_plugin_page() {
	echo '<div class="wrap">';
	echo '<h1>Example Plugin</h1>';
	echo '<div class="card"><p>';

	if ( Imagify_Partner::is_imagify_activated() ) {
		// Imagify is activated, the user only needs to set the API key (the 3 steps banner should be displaying).
		if ( Imagify_Partner::is_success() ) {
			_e( 'Imagify has been successfully activated.', 'example-plugin' );
		} else {
			_e( 'Imagify is already activated.', 'example-plugin' );
		}
	} else {
		$imagify = new Imagify_Partner( EXAMPLE_IMAGIFY_PARTNER_ID );

		if ( Imagify_Partner::is_imagify_installed() ) {
			$button_text = __( 'Activate Imagify', 'example-plugin' );
		} else {
			$button_text = __( 'Install and activate Imagify', 'example-plugin' );
		}

		echo '<a class="button-primary" href="' . esc_url( $imagify->get_post_install_url() ) . '">' . $button_text . '</a>';
	}

	echo '</p></div>';
	echo '</div>';
}