Skip to content

Instantly share code, notes, and snippets.

@jarednova
Created May 5, 2016 14:29
Show Gist options
  • Save jarednova/e8a18361412ee4e7c40297ef815e714e to your computer and use it in GitHub Desktop.
Save jarednova/e8a18361412ee4e7c40297ef815e714e to your computer and use it in GitHub Desktop.
<?php
class TimberAdmin {
public static function init() {
$action = add_action('in_plugin_update_message-timber-library/timber.php', array(__CLASS__, 'in_plugin_update_message'), 10, 2);
return add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
}
/**
* @param array $links
* @param string $file
* @return array
*/
public static function meta_links( $links, $file ) {
if ( strstr( $file, '/timber.php' ) ) {
unset($links[2]);
$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&amp;plugin=timber-library&amp;TB_iframe=true&amp;width=600&amp;height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
$links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
$links[] = '<a href="https://github.com/jarednova/timber/wiki" target="_blank">Documentation</a>';
$links[] = '<a href="https://github.com/jarednova/timber/wiki/getting-started" target="_blank">Starter Guide</a>';
return $links;
}
return $links;
}
/**
* in_plugin_update_message
*
* Displays an update message for plugin list screens.
* Shows only the version updates from the current until the newest version
*
* @type function
* @date 4/22/16
*
* @param {array} $plugin_data
* @param {object} $r
*/
public static function in_plugin_update_message( $plugin_data, $r ) {
$m = '<hr />';
if ( version_compare("1.0.0", $plugin_data->new_version, "<=") ) {
$m .= '<p><b>Warning:</b> Timber 1.0 removed a number of features and methods. Before upgrading please test your theme on a local or staging site to ensure that your theme will work with the newest version.</p>';
} else if ( version_compare("1.0.0", $plugin_data->Version, ">") ) {
$m .= '<p><b>Warning:</b> Timber 1.0 will remove a number of features and methods. Before upgrading please test your theme on a local or staging site to ensure that your theme will work with the newest version.</p>';
}
$m .= '<p><strong>Is your theme in active development?</strong> That is, is someone actively in PHP files writing new code? If you answered "no", then <i>do not upgrade to version 1.0</i>. You will not benefit from Timber 1.0</p>';
$m .= '<p>Read the <strong><a href="https://github.com/timber/timber/wiki/1.0-Upgrade-Guide">Upgrade Guide</a></strong> for more information</p>';
if ( version_compare("0.22.6", $plugin_data->Version) > 0 ) {
$m .= "<p>You can <b><a href='https://downloads.wordpress.org/plugin/timber-library.0.22.6.zip'>upgrade to version 0.22.6</a></b> if you want to upgrade, but are unsure if you're ready for 1.0";
}
// show message
echo '<br />'.sprintf($m, admin_url('edit.php?post_type=acf-field-group&page=acf-settings-updates'), 'http://www.advancedcustomfields.com/pro');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment