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(); } 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" => __('Active', 'affiliate')); $columns = apply_filters('affiliate_plugincolumns', $columns); $plugins = get_affiliate_addons(); $active = 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)) { foreach ($plugins as $key => $plugin) { $default_headers = array('Name' => 'Plugin Name', 'Author' => 'Author', 'Description' => 'Description', 'AuthorURI' => 'Author URI'); $plugin_data = get_file_data(affiliate_dir('affiliateincludes/addons/' . $plugin), $default_headers, 'plugin'); if (empty($plugin_data['Name'])) { continue; } ?> <tr valign="middle" class="alternate" id="plugin-<?php echo $plugin; ?> "> <th class="check-column" scope="row"><input type="checkbox" value="<?php echo esc_attr($plugin); ?> " name="plugincheck[]"></th> <td class="column-name"> <strong><?php echo esc_html($plugin_data['Name']) . "</strong>"; ?> <?php if (!empty($plugin_data['Description'])) { ?> <br/><?php echo esc_html($plugin_data['Description']); } $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) . "'>" . __('Activate', 'affiliate') . "</a></span>"; } ?> <br><div class="row-actions"><?php echo implode(" | ", $actions); ?> </div> </td> <td class="column-active"> <?php 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 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 }