id = $id;
$this->msg = $msg;
$this->class = $class;
$this->hide_hide = $hide_hide;
/* Display a notice that can be dismissed */
add_action('admin_notices', array($this,'hmg_admin_notice'));
add_action('admin_init', array($this,'hmg_nag_ignore'));
if ($filter) {
return add_filter($filter, array($this,'hmg_admin_notice') );
}
}
public function hmg_admin_notice() {
global $current_user ;
$user_id = $current_user->ID;
/* Check that the user hasn't already clicked to ignore the message */
if ( ! get_user_meta($user_id, $this->id . '_ignore_notice') ) {
echo "
";
}
}
public function hmg_nag_ignore() {
global $current_user;
$user_id = $current_user->ID;
/* If user clicks to ignore the notice, add that to their user meta */
if ( isset($_GET[$this->id . '_ignore_notice']) && '0' == $_GET[$this->id . '_ignore_notice'] ) {
add_user_meta($user_id, $this->id . '_ignore_notice', 'true', true);
}
}
}
}
if ( defined(FTU_VERSION) && version_compare(FTU_VERSION, $this_FTU_version, '<') ) {
$FTU_version_obj = new FTU_Admin_Notices( 'ftuversion', 'Oh no, you have an older version of the core FTU library installed. To fix this, please update all your 42U plugins to the latest version.', 'error', true);
}
if (!class_exists("FTU") || ( version_compare(FTU_VERSION, $this_FTU_version, '<') && version_compare(PHP_VERSION, '5.3', '>=') ) ) {
define( 'FTU_VERSION', '1.0' );
define( 'FTU_REQUIRED_WP_VERSION', '3.2' );
define( 'FTU_REQUIRED_PHP_VERSION', '5.2' );
/*
if (version_compare(PHP_VERSION, '5.3', '>=') && version_compare(FTU_VERSION, $this_FTU_version, '<') ) {
# should be able to reclass this using a namespace
namespace FTUnamespace10;
}
*/
if ( version_compare($wp_version, FTU_REQUIRED_WP_VERSION, '<') ) {
$php_version_obj = new FTU_Admin_Notices( 'wpversion', 'Oh no, 42U plugins need at least WordPress version ' . FTU_REQUIRED_WP_VERSION . ' Some functions probably won\'t work.', 'error');
}
if ( version_compare(PHP_VERSION, FTU_REQUIRED_PHP_VERSION, '<') ) {
$php_version_obj = new FTU_Admin_Notices( 'phpversion', 'Oh no, 42U plugins need at least PHP version ' . FTU_REQUIRED_PHP_VERSION . ' Some functions probably won\'t work.', 'error');
}
class FTU {
public function __construct(){
/* Custom Post Type Icon for Admin Menu & Post Screen */
add_action( 'admin_head', array($this,'set_post_type_icon_cb'));
add_action('admin_menu', array($this,'register_42U_mainpage'));
}
public function register_42U_mainpage() {
$main_page = add_menu_page('42 Umbrellas', '42 Umbrellas', 'administrator', '42-Umbrellas', array($this,'fortytwou_init'),'div');//plugins_url('myplugin/images/icon.png')
wp_register_style( 'ftUStylesheet', plugins_url('../css/style.css', __FILE__) );
add_action( 'admin_print_styles-' . $main_page, array($this, 'add_42U_stylesheet') );
}
public function fortytwou_init() {
include_once('splash.php');
}
public function add_42U_stylesheet() {
wp_enqueue_style( 'ftUStylesheet' );
}
public function show_42U_message($msg,$class) {
$class = (empty($class)) ? 'updated' : $class;
?>
0755,'filePermission'=>0755)) {
$result=false;
if (is_file($source)) {
if ($dest[strlen($dest)-1]=='/') {
if (!file_exists($dest)) {
cmfcDirectory::makeAll($dest,$options['folderPermission'],true);
}
$__dest=$dest."/".basename($source);
} else {
$__dest=$dest;
}
$result=copy($source, $__dest);
chmod($__dest,$options['filePermission']);
} elseif(is_dir($source)) {
if ($dest[strlen($dest)-1]=='/') {
if ($source[strlen($source)-1]=='/') {
//Copy only contents
} else {
//Change parent itself and its contents
$dest=$dest.basename($source);
@mkdir($dest);
chmod($dest,$options['filePermission']);
}
} else {
if ($source[strlen($source)-1]=='/') {
//Copy parent directory with new name and all its content
@mkdir($dest,$options['folderPermission']);
chmod($dest,$options['filePermission']);
} else {
//Copy parent directory with new name and all its content
@mkdir($dest,$options['folderPermission']);
chmod($dest,$options['filePermission']);
}
}
$dirHandle=opendir($source);
while($file=readdir($dirHandle)) {
if($file!="." && $file!="..") {
if(!is_dir($source."/".$file)) {
$__dest=$dest."/".$file;
} else {
$__dest=$dest."/".$file;
}
//echo "$source/$file ||| $__dest ";
$result=FTU::smartCopy($source."/".$file, $__dest, $options);
}
}
closedir($dirHandle);
} else {
$result=false;
}
return $result;
}
public function license($key,$product) {
$license = get_option("_hmg_license");
$hash = md5($key . $product);
$validity = 0;
$owner = '';
$url = "http://admin.haleymarketing.com/json/?k=$key&p=$product&pid=gwt&arg=validate_license";
$whetherUpdateLicense = false;
if (!($key && $product)) {
return array("last_update"=>time(),"validity"=>false,"owner"=>$owner);
}
if (isset($license[$hash])){
$timeOfLastFetch = intval(@$license[$hash]["last_update"]);
if (time()-$timeOfLastFetch > 500) { //update the license every 500 minutes
$whetherUpdateLicense = true;
} else {
if ($license[$hash]['validity'] == true) {
return $license[$hash];
} else {
$whetherUpdateLicense = true;
}
}
} else {
$whetherUpdateLicense = true;
}
if ($whetherUpdateLicense) {
if ($result = file_get_contents($url)) {
$result = json_decode($result);
$validity = intval($result->ResultSet->validity) ? true : false;
$owner = $result->ResultSet->owner;
}
$license = get_option("_hmg_license");
$license[$hash] = array("last_update"=>time(),"validity"=>$validity,"owner"=>$owner);
update_option("_hmg_license",$license);
}
return $license[$hash];
}
public function set_post_type_icon_cb() {
FTU::set_post_type_icon($image_urls=array('plugin'=>'42-Umbrellas',
'admin-image'=>'images/42U_adminmenu16-sprite.png',
'posts-image'=>'images/42U_adminpage32.png',
'admin-imageX2'=>'images/42U_adminmenu16-sprite_2x.png',
'posts-imageX2'=>'images/42U_adminpage32_2x.png',
'file' => __FILE__
));
}
public function set_post_type_icon($image_urls=array('plugin'=>'42-Umbrellas',
'admin-image'=>'images/42U_adminmenu16-sprite.png',
'posts-image'=>'images/42U_adminpage32.png',
'admin-imageX2'=>'images/42U_adminmenu16-sprite_2x.png',
'posts-imageX2'=>'images/42U_adminpage32_2x.png',
'file' => __FILE__
)) {
?>
=') && version_compare(FTU_VERSION, $this_FTU_version, '<') ) {
# should be able to reclass this using a namespace
use FTUnamespace10\FTU as FTU;
}
*/
$fortytwou = new FTU();
}
/* Helper Class for version checking */
/* Helper Class for options frame work */
/* Helper Class for checking for plugin dependencies */
if (!class_exists('Theme_Plugin_Dependency')) {
// we need this to enable plugin checks outside of admin
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
class Theme_Plugin_Dependency {
// input information from the theme
var $slug;
var $uri;
// installed plugins and uris of them
private $plugins; // holds the list of plugins and their info
private $uris; // holds just the URIs for quick and easy searching
// both slug and PluginURI are required for checking things
function __construct( $slug, $uri ) {
$this->slug = $slug;
$this->uri = $uri;
if ( empty( $this->plugins ) )
$this->plugins = get_plugins();
if ( empty( $this->uris ) )
$this->uris = wp_list_pluck($this->plugins, 'PluginURI');
}
// return true if installed, false if not
function check() {
return in_array($this->uri, $this->uris);
}
// return true if installed and activated, false if not
function check_active() {
$plugin_file = $this->get_plugin_file();
if ($plugin_file) return is_plugin_active($plugin_file);
return false;
}
// gives a link to activate the plugin
function activate_link() {
$plugin_file = $this->get_plugin_file();
if ($plugin_file) return wp_nonce_url(self_admin_url('plugins.php?action=activate&plugin='.$plugin_file), 'activate-plugin_'.$plugin_file);
return false;
}
// return a nonced installation link for the plugin. checks wordpress.org to make sure it's there first.
function install_link() {
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
$info = plugins_api('plugin_information', array('slug' => $this->slug ));
if ( is_wp_error( $info ) )
return false; // plugin not available from wordpress.org
return wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $this->slug), 'install-plugin_' . $this->slug);
}
// return array key of plugin if installed, false if not, private because this isn't needed for themes, generally
private function get_plugin_file() {
return array_search($this->uri, $this->uris);
}
}
}
/* Helper Class for admin notices */
if (!class_exists('FTU_Admin_Notices')) {
class FTU_Admin_Notices {
// input information
var $id;
var $msg;
var $class;
var $hide_hide;
public function __construct($id,$msg,$class,$hide_hide,$filter = ''){
$this->id = $id;
$this->msg = $msg;
$this->class = $class;
$this->hide_hide = $hide_hide;
/* Display a notice that can be dismissed */
add_action('admin_notices', array($this,'hmg_admin_notice'));
add_action('admin_init', array($this,'hmg_nag_ignore'));
if ($filter) {
return add_filter($filter, array($this,'hmg_admin_notice') );
}
}
public function hmg_admin_notice() {
global $current_user ;
$user_id = $current_user->ID;
/* Check that the user hasn't already clicked to ignore the message */
if ( ! get_user_meta($user_id, $this->id . '_ignore_notice') ) {
echo "