folders, $folders);
}
/**
* Applies the configuration of the plugin
* @var array $config The config that is to be edited
* @return array The new config
*/
public function applyConfig($config) {
$config['tabs'] = array(
0 => array( 'Settings', 'tabs__settings_withinboredom'),
1 => array('About', 'tabs__about_withinboredom'),
2 => array('Support', 'tabs__support_withinboredom'),
);
$config['help'] = array(
// The tab to display on
'0' => array(
// The title content of the help menu
0 => array('Overview', "Basic settings for the Abundatrade Calculator."),
1 => array('Help', 'Enter your affiliate id and the location of your thank you page')
)
);
$config['config'] = array(
'settings' => true,
'page_title' => 'Abundatrade',
'button_title' => 'Abundatrade',
'slug' => 'abundatrade',
'shortcodes' => array(
'abundatrade'
),
);
return $config;
}
public function shortcode($atts) {
if (!isset($atts['gadget_only'])) $atts['gadget_only'] = false;
if ($atts['gadget_only']) {
$hide = ' display: none;';
$gadget_state = ' ';
}
else {
$hide = ' ';
$gadget_state = ' display: none;';
}
$display = '
Enter an item UPC, ISBN, or EAN to see its value here
';
$very_bottom = '
';
$gadget_begin = '
';
$gadget_manufacturer = '';
$gadget_category = '';
$gadget_selector =
'';
$status = "";
$display .= $status;
$display .= $bulk;
$display .= $gadget_begin;
$display .= $gadget_selector;
$display .= $endtop;
$display .= $top;
$display .= $endform;
$display .= $bulk_button;
$display .= $second;
$display .= $table;
$display .= $very_bottom;
$display .= $endtop;
return $display;
}
/**
* Retuns a pointer to the settings object
*/
public function getSettings() {
return array(&$this->settings);
}
public function doshortcode($atts) {
$display = apply_filters("abundatrade(shortcode(abundatrade))", $atts);
return $display;
}
public function addScripts() {
if (file_exists($this->folders['UploadsDir']['basedir'] . '/abundatrade/themes/' . $this->settings->Theme . '.css')) {
wp_register_style("abundatrade_classic", $this->folders['UploadsDir']['baseurl'] . '/abundatrade/themes/' . $this->settings->Theme . '.css');
}
else if (file_exists($this->folders['PluginDir'] . '/themes/' . $this->settings->Theme . '.css')) {
wp_register_style("abundatrade_classic", $this->folders['PluginUrl'] . '/themes/' . $this->settings->Theme . '.css');
}
else {
wp_register_style("abundatrade_classic", $this->folders['PluginUrl'] . '/themes/classic.css');
}
if (file_exists($this->folders['UploadsDir']['basedir'] . '/abundatrade/themes/' . $this->settings->Theme . '-prompt.css')) {
wp_register_style("abundatrade_prompt_classic", $this->folders['UploadsDir']['baseurl'] . '/abundatrade/themes/' . $this->settings->Theme . '-prompt.css');
}
else if (file_exists($this->folders['PluginDir'] . '/themes/' . $this->settings->Theme . '-prompt.css')) {
wp_register_style("abundatrade_prompt_classic", $this->folders['PluginUrl'] . '/themes/' . $this->settings->Theme . '-prompt.css');
}
else {
wp_register_style("abundatrade_prompt_classic", $this->folders['PluginUrl'] . '/themes/classic-prompt.css');
}
wp_register_script("abundatrade_md5", $this->folders['PluginUrl'] . '/js/MD5.js');
wp_register_script("abundatrade_remote", $this->folders['PluginUrl'] . '/js/remote.js', array('jquery','abundatrade_md5'));
wp_register_script("abundatrade_impromptu", $this->folders['PluginUrl'] . '/js/jquery-impromptu.4.0.min.js', array('jquery'));
wp_register_script("abundatrade_register", $this->folders['PluginUrl'] . '/js/register.js', array('jquery', 'abundatrade_remote'));
wp_enqueue_style("abundatrade_classic");
wp_enqueue_style("abundatrade_prompt_classic");
wp_enqueue_script("abundatrade_md5");
wp_enqueue_script("abundatrade_remote");
wp_enqueue_script("abundatrade_impromptu");
wp_enqueue_script("abundatrade_register");
$abundacalc = array('server' => 'abundatrade.com',
'url' => $this->folders['PluginUrl'],
'thanks' => $this->settings->Thank_you_page);
if (isset($_REQUEST['upload_id']) && $_REQUEST['upload_id'] != '') {
$abundacalc['upload_id'] = $_REQUEST['upload_id'];
}
wp_localize_script('abundatrade_remote','abundacalc',$abundacalc);
}
/**
* Creates a map structure
*/
function __construct() {
$this->BuildFolderList();
add_filter("abundatrade(getFolders)", array(&$this, "getFolders"), 1);
add_filter("abundatrade(applyConfig)", array(&$this, "applyConfig"), 1);
add_filter("abundatrade(shortcode(abundatrade))", array(&$this, "shortcode"), 1);
add_shortcode("abundatrade", array($this, "doshortcode"));
add_filter("abundatrade(settings)", array($this, "getSettings"), 200, 0);
add_action("wp_enqueue_scripts", array($this, "addScripts"));
spl_autoload_register(array($this, "autoload"));
$skel = new skel__skel();
//load settings last for updates
$this->settings = new skel__settings();
}
/**
* Autoloads all classes as required to only load in what we need
* @var string $classname The name of the class to load
*/
static public function autoload($classname) {
$file = str_replace("__", "/", $classname);
$folders = apply_filters("abundatrade(getFolders)", array());
if (file_exists($folders['PluginDir'] . $file . ".php"))
include_once($folders['PluginDir'] . $file . ".php");
//else
//echo "
file no exists: " . $folders['PluginDir'] . $file . ".php\n
";
}
/**
* Builds a list of folders for later distribution so we can find ourselves
* call with apply_filters("abundatrade(getFolders", array());
*/
private function BuildFolderList() {
$config = $this->applyConfig(array());
$this->folders = array();
$this->folders['UploadsDir'] = wp_upload_dir();
$this->folders['PluginDir'] = plugin_dir_path(__FILE__);
$this->folders['PluginUrl'] = plugins_url('', __FILE__);
$this->folders['PluginAdmin'] = admin_url() . 'options-general.php?page=' . $config['config']['slug'];
$this->folders['Basename'] = plugin_basename(__FILE__);
}
}
$GLOBALS['abundatrade_withinboredom'] = new abundatrade_withinboredom();
//we don't want to autoload later on
//spl_autoload_unregister(array($GLOBALS['TheMap_withinboredom'], 'autoload'));