function affiliate_marketpress_display_metabox($order) { //echo "order<pre>"; print_r($order); echo "</pre>"; if (isset($order->mp_shipping_info['affiliate_referrer']) && !empty($order->mp_shipping_info['affiliate_referrer'])) { ?> <div id="mp-order-notes-affiliate" class="postbox"> <h3 class='hndle'><span><?php _e('Affiliate', 'affiliate'); ?> </span> - <span class="description"><?php _e('This order was received via an Affiliate Referrer link.', 'affiliate'); ?> </span></h3> <div class="inside"> <?php //echo "order status[". $order->post_status ."]<br />"; if ($order->post_status == "order_received") { ?> <p><?php _e("Affiliate information will be displayed when the order status is changed to 'paid'", 'affiliate'); ?> </p><?php } else { if ($order->post_status == 'order_paid' || $order->post_status == 'order_shipped' || $order->post_status == 'order_closed') { //echo $order->mp_shipping_info['affiliate_referrer']."<br />"; //echo "order<pre>"; print_r($order); echo "</pre>"; $user = new WP_User(intval($order->mp_shipping_info['affiliate_referrer'])); if ($user) { //echo "user<pre>"; print_r($user); echo "</pre>"; if (affiliate_is_plugin_active_for_network()) { if (current_user_can('manage_network_options')) { ?> <p><?php _e('Affiliate User', 'affiliate'); ?> <a href="<?php echo network_admin_url('admin.php?page=affiliatesadminmanage&subpage=details&id=' . $user->ID); ?> "><?php echo $user->display_name; ?> (<?php echo $user->user_email; ?> )</a></p><?php } else { ?> <p><?php echo $user->display_name; ?> </p><?php } } else { if (current_user_can('edit_others_posts')) { ?> <p><?php _e('Affiliate User', 'affiliate'); ?> <a href="<?php echo admin_url('admin.php?page=affiliatesadminmanage&subpage=details&id=' . $user->ID); ?> "><?php echo $user->display_name; ?> (<?php echo $user->user_email; ?> )</a></p><?php } else { ?> <p><?php echo $user->display_name; ?> </p><?php } } if (isset($_GET['order_id']) && !empty($_GET['order_id'])) { global $affadmin; $affadmin->show_complete_records_table($order->mp_shipping_info['affiliate_referrer'], false, array('paid:marketpress'), intval($_GET['order_id'])); } } } } ?> </div> </div> <?php } }
function install() { return; // The install is done via the admin class on plugin activation. WTF is this doing here? // This shouldn't really need to be called as the admin area will set up the tables - but just in case if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliatedata . "' ") != $this->affiliatedata) { $charset_collate = ''; if (!empty($this->db->charset)) { $charset_collate = "DEFAULT CHARACTER SET " . $this->db->charset; } if (!empty($this->db->collate)) { $charset_collate .= " COLLATE " . $this->db->collate; } $sql = "CREATE TABLE `" . $this->affiliatedata . "` (\n\t\t\t \t`user_id` bigint(20) default NULL,\n\t\t\t \t`period` varchar(6) default NULL,\n\t\t\t \t`uniques` bigint(20) default '0',\n\t\t\t \t`signups` bigint(20) default '0',\n\t\t\t \t`completes` bigint(20) default '0',\n\t\t\t \t`debits` decimal(10,2) default '0.00',\n\t\t\t \t`credits` decimal(10,2) default '0.00',\n\t\t\t \t`payments` decimal(10,2) default '0.00',\n\t\t\t \t`lastupdated` datetime default '0000-00-00 00:00:00',\n\t\t\t \tUNIQUE KEY `user_period` (`user_id`,`period`)\n\t\t\t\t) {$charset_collate};"; $this->db->query($sql); $sql = "CREATE TABLE `" . $this->affiliatereferrers . "` (\n\t\t\t \t`user_id` bigint(20) default NULL,\n\t\t\t \t`period` varchar(6) default NULL,\n\t\t\t \t`url` varchar(250) default NULL,\n\t\t\t \t`referred` bigint(20) default '0',\n\t\t\t \tUNIQUE KEY `user_id` (`user_id`,`period`,`url`)\n\t\t\t\t) {$charset_collate};"; $this->db->query($sql); } if ($this->db->get_var("SHOW TABLES LIKE '" . $this->affiliaterecords . "' ") != $this->affiliaterecords) { $sql = "CREATE TABLE `" . $this->affiliaterecords . "` (\n\t\t\t \t`user_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t `period` varchar(6) DEFAULT NULL,\n\t\t\t\t `affiliatearea` varchar(50) DEFAULT NULL,\n\t\t\t\t `area_id` bigint(20) DEFAULT NULL,\n\t\t\t\t `affiliatenote` text,\n\t\t\t\t `amount` decimal(10,2) DEFAULT NULL,\n\t\t\t\t KEY `user_id` (`user_id`),\n\t\t\t\t KEY `period` (`period`)\n\t\t\t\t) {$charset_collate};"; $this->db->query($sql); } if (affiliate_is_plugin_active_for_network() && (defined('AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED') && AFFILIATE_USE_GLOBAL_IF_NETWORK_ACTIVATED == 'yes')) { // We need to check for a transfer across from old options to new ones $option = aff_get_option('affiliateheadings', false); if ($option == false) { $option = get_blog_option(1, 'affiliateheadings'); aff_update_option('affiliateheadings', $option); } $option = aff_get_option('affiliatesettingstext', false); if ($option == false) { $option = get_blog_option(1, 'affiliatesettingstext'); aff_update_option('affiliatesettingstext', $option); } $option = aff_get_option('affiliateadvancedsettingstext', false); if ($option == false) { $option = get_blog_option(1, 'affiliateadvancedsettingstext'); aff_update_option('affiliateadvancedsettingstext', $option); } $option = aff_get_option('affiliateenablebanners', false); if ($option == false) { $option = get_blog_option(1, 'affiliateenablebanners'); aff_update_option('affiliateenablebanners', $option); } $option = aff_get_option('affiliatelinkurl', false); if ($option == false) { $option = get_blog_option(1, 'affiliatelinkurl'); aff_update_option('affiliatelinkurl', $option); } $option = aff_get_option('affiliatebannerlinks', false); if ($option == false) { $option = get_blog_option(1, 'affiliatebannerlinks'); aff_update_option('affiliatebannerlinks', $option); } $option = aff_get_option('affiliate_activated_addons', false); if ($option == false) { $option = get_blog_option(1, 'affiliate_activated_addons'); aff_update_option('affiliate_activated_addons', $option); } } }
function handle_addons_panel() { global $action, $page, $subpage; wp_reset_vars(array('action', 'page', 'subpage')); $messages = array(); $messages[1] = __('Addon updated.', 'affiliate'); $messages[2] = __('Addon not updated.', 'affiliate'); $messages[3] = __('Addon activated.', 'affiliate'); $messages[4] = __('Addon not activated.', 'affiliate'); $messages[5] = __('Addon deactivated.', 'affiliate'); $messages[6] = __('Addon not deactivated.', 'affiliate'); $messages[7] = __('Addon activation toggled.', 'affiliate'); if (!empty($action)) { $msg = $this->handle_addons_panel_updates(); } //$mu_plugins = get_mu_plugins(); //echo "mu_plugins<pre>"; print_r($mu_plugins); echo "</pre>"; //$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins'); //echo "network active plugins<pre>"; print_r($active_sitewide_plugins); echo "</pre>"; //$active_plugins = get_option( 'active_plugins', array()); //echo "active plugins<pre>"; print_r($active_plugins); echo "</pre>"; if (!empty($msg)) { echo '<div id="message" class="updated fade"><p>' . $messages[(int) $msg] . '</p></div>'; $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); } ?> <form method="get" action="?page=<?php echo esc_attr($page); ?> &subpage=<?php echo esc_attr($subpage); ?> " id="posts-filter"> <input type='hidden' name='page' value='<?php echo esc_attr($page); ?> ' /> <input type='hidden' name='subpage' value='<?php echo esc_attr($subpage); ?> ' /> <div class="tablenav"> <div class="alignleft actions"> <select name="action"> <option selected="selected" value=""><?php _e('Bulk Actions', 'affiliate'); ?> </option> <option value="toggle"><?php _e('Toggle activation', 'affiliate'); ?> </option> </select> <input type="submit" class="button-secondary action" id="doaction" name="doaction" value="<?php _e('Apply', 'affiliate'); ?> "> </div> <div class="alignright actions"></div> <br class="clear"> </div> <div class="clear"></div> <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('bulk-addon'); $columns = array("name" => __('Addon Name', 'affiliate'), "active" => __('Addon Status', 'affiliate')); $columns = apply_filters('affiliate_plugincolumns', $columns); $plugins = get_affiliate_addons(); $active = aff_get_option('affiliate_activated_addons', array()); ?> <table cellspacing="0" class="widefat fixed"> <thead> <tr> <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox"></th> <?php foreach ($columns as $key => $col) { ?> <th style="" class="manage-column column-<?php echo $key; ?> " id="<?php echo $key; ?> " scope="col"><?php echo $col; ?> </th> <?php } ?> </tr> </thead> <tfoot> <tr> <th style="" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th> <?php reset($columns); foreach ($columns as $key => $col) { ?> <th style="" class="manage-column column-<?php echo $key; ?> " id="<?php echo $key; ?> " scope="col"><?php echo $col; ?> </th> <?php } ?> </tr> </tfoot> <tbody> <?php if (!empty($plugins)) { $AFFILIATE_IS_NETWORK_ACTIVE = affiliate_is_plugin_active_for_network(); foreach ($plugins as $key => $plugin) { $default_headers = array('Name' => 'Plugin Name', 'Description' => 'Description', 'AuthorURI' => 'Author URI', 'Network' => 'Network', 'Depends' => 'Depends', 'Class' => 'Class', 'Deprecated' => 'Deprecated'); $plugin_data = get_file_data(affiliate_dir('affiliateincludes/addons/' . $plugin), $default_headers, 'plugin'); //echo "plugin_data<pre>"; print_r($plugin_data); echo "</pre>"; if (empty($plugin_data['Name'])) { continue; } if (!isset($plugin_data['Network']) || empty($plugin_data['Network']) || $plugin_data['Network'] != 'true') { $plugin_data['Network'] = false; } else { if ($plugin_data['Network'] == 'true') { $plugin_data['Network'] = true; } } if ($plugin_data['Network'] == true && !is_multisite() && is_network_admin()) { continue; } //echo "plugin_data<pre>"; print_r($plugin_data); echo "</pre>"; $PLUGINS_CAN_BE_ACTIVE = true; if ($plugin_data['Network'] == true && !$AFFILIATE_IS_NETWORK_ACTIVE) { $PLUGINS_CAN_BE_ACTIVE = false; } //echo "[". $plugin_data['Name'] ."] PLUGINS_CAN_BE_ACTIVE[". $PLUGINS_CAN_BE_ACTIVE ."]<br />"; // Set the initial active $PLUGIN_INSTALLED = true; if (!isset($plugin_data['Depends']) || empty($plugin_data['Depends'])) { $plugin_data['Network'] = array(); if (isset($plugin_data['Class']) && !empty($plugin_data['Class'])) { if (!class_exists($plugin_data['Class'])) { $PLUGIN_INSTALLED = false; } } } else { $depends = explode(',', $plugin_data['Depends']); if ($depends && is_array($depends) && count($depends)) { foreach ($depends as $depend) { //echo "depend[". $depend ."]<br />"; if (!affiliate_is_plugin_active($depend) && !affiliate_is_plugin_active_for_network($depend)) { if (isset($plugin_data['Class']) || !empty($plugin_data['Class'])) { //echo "class[". $plugin_data['Class'] ."]<br />"; if (!class_exists($plugin_data['Class'])) { $PLUGIN_INSTALLED = false; } } else { $PLUGIN_INSTALLED = false; } } } } } //echo "[". $plugin_data['Name'] ."] PLUGIN_INSTALLED[". $PLUGIN_INSTALLED ."]<br />"; if ('yes' == $plugin_data['Deprecated'] && !$PLUGIN_INSTALLED) { // We only display deprecated Add-Ons when the deprecated dependency is installed. continue; } ?> <tr valign="middle" class="alternate" id="plugin-<?php echo $plugin; ?> "> <th class="check-column" scope="row"> <?php if ($PLUGINS_CAN_BE_ACTIVE && $PLUGIN_INSTALLED) { ?> <input type="checkbox" value="<?php echo esc_attr($plugin); ?> " name="plugincheck[]"><?php } ?> </th> <td class="column-name"> <strong><?php echo esc_html($plugin_data['Name']); ?> </strong> <?php if (!$PLUGIN_INSTALLED) { //echo ' <span>'. __('Base plugin not activate/installed', 'affiliate') .'</span>'; echo ' -- <strong>' . __('plugin not installed', 'affiliate') . '</strong>'; } if (!empty($plugin_data['Description'])) { ?> <br/><?php echo esc_html($plugin_data['Description']); } //if ($plugin_data['Network'] == true) { // echo '<br /><strong>' .__('Network only - Requires Affiliate plugin is Network Activated', 'affiliate') .'</strong>'; //} if ($PLUGINS_CAN_BE_ACTIVE && $PLUGIN_INSTALLED) { $actions = array(); if (in_array($plugin, $active)) { $actions['toggle'] = "<span class='edit activate'><a href='" . wp_nonce_url("?page=" . $page . "&subpage=" . $subpage . "&action=deactivate&addon=" . $plugin . "", 'toggle-addon-' . $plugin) . "'>" . __('Deactivate', 'affiliate') . "</a></span>"; } else { $actions['toggle'] = "<span class='edit deactivate'><a href='" . wp_nonce_url("?page=" . $page . "&subpage=" . $subpage . "&action=activate&addon=" . $plugin . "", 'toggle-addon-' . $plugin) . "'>" . (function_exists('is_network_admin') && is_network_admin() ? __('Network Activate', 'affiliate') : __('Activate', 'affiliate')) . "</a></span>"; } if (count($actions)) { ?> <br /><div class="row-actions"><?php echo implode(" | ", $actions); ?> </div><?php } } ?> </td> <td class="column-active"> <?php if ($PLUGINS_CAN_BE_ACTIVE && $PLUGIN_INSTALLED) { if (in_array($plugin, $active)) { echo "<strong>" . __('Active', 'affiliate') . "</strong>"; } else { echo __('Inactive', 'affiliate'); } } ?> </td> </tr> <?php } } else { $columncount = count($columns) + 1; ?> <tr valign="middle" class="alternate" > <td colspan="<?php echo $columncount; ?> " scope="row"><?php _e('No Addons where found for this install.', 'affiliate'); ?> </td> </tr> <?php } ?> </tbody> </table> <div class="tablenav"> <div class="alignleft actions"> <select name="action2"> <option selected="selected" value=""><?php _e('Bulk Actions', 'affiliate'); ?> </option> <option value="toggle"><?php _e('Toggle activation', 'affiliate'); ?> </option> </select> <input type="submit" class="button-secondary action" id="doaction2" name="doaction2" value="Apply"> </div> <div class="alignright actions"></div> <br class="clear"> </div> </form> <?php }
function aff_delete_option($option) { if (affiliate_is_plugin_active_for_network()) { return delete_site_option($option); } else { return delete_option($option); } }