lbrypress/lbrypress.php
Paul Kirby 59c3118c79 Began working on dependency injection style
infrastructure. initial work on settings page template
2018-08-31 20:14:12 -05:00

109 lines
3.5 KiB
PHP

<?php
/**
* @package LBRYPress
*/
/*
Plugin Name: LBRYPress
Plugin URI:
Description: Connect your wordpress posts to
Version: 0.0.1
Author: Underground Web Lab
Author URI: https://undergroundweblab.com
License: MIT License
Text Domain: lbrypress
Copyright 2018 Underground Web Lab
// TODO: Finalize License Verbage
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
defined('ABSPATH') || die('No Peeking!');
// Global Constants
define('LBRY_NAME', 'LBRYPress');
define('LBRY_URI', dirname(__FILE__));
define('LBRY_REQUIRED_PHP_VERSION', '5.3'); // TODO: Figure out what versions we actually need
define('LBRY_REQUIRED_WP_VERSION', '3.1');
// Library Options Names
define('LBRY_WALLET', 'lbry_wallet'); // the wallet address
define('LBRY_SPEECH', 'lbry_speech'); // the spee.ch address
define('LBRY_LICENSE', 'lbry_license'); // the license to publish with to the LBRY network
define('LBRY_LBC_PUBLISH', 'lbry_lbc_publish'); // amount of lbc to use per publish
/**
* Checks if the system requirements are met
*
* @return bool True if system requirements are met, false if not
*/
function lbry_requirements_met()
{
global $wp_version;
//require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); // to get is_plugin_active() early
if (version_compare(PHP_VERSION, LBRY_REQUIRED_PHP_VERSION, '<')) {
return false;
}
if (version_compare($wp_version, LBRY_REQUIRED_WP_VERSION, '<')) {
return false;
}
return true;
}
/**
* Prints an error that the system requirements weren't met.
*/
function lbry_requirements_error()
{
global $wp_version;
require_once(LBRY_URI . '/templates/requirements-error.php');
}
/**
* Autoloader Registration
*/
function lbry_autoload_register($class)
{
$file_name = LBRY_URI . '/classes/' . $class . '.php';
if (file_exists($file_name)) {
require $file_name;
return;
}
}
spl_autoload_register('lbry_autoload_register');
/**
* Check requirements and load main class
* The main program needs to be in a separate file that only gets loaded if the plugin requirements are met. Otherwise older PHP installations could crash when trying to parse it.
*/
if (lbry_requirements_met()) {
add_action('init', function () {
$LBRYPress = new LBRYPress();
$LBRYPress->init();
});
// register_activation_hook(__FILE__, function () {
// LBRYPress::get_instance()->activate();
// });
//
// register_deactivation_hook(__FILE__, function () {
// LBRYPress::get_instance()->deactivate();
// });
} else {
add_action('admin_notices', 'lbry_requirements_error');
}
/**
* Admin Set up
*/