function create_plugins_box() { $all = AgmPluginsHandler::get_all_plugins(); $active = AgmPluginsHandler::get_active_plugins(); $sections = array('thead', 'tfoot'); echo "<table class='widefat'>"; foreach ($sections as $section) { echo "<{$section}>"; echo '<tr>'; echo '<th width="30%">' . __('Add-on name', 'agm_google_maps') . '</th>'; echo '<th>' . __('Add-on description', 'agm_google_maps') . '</th>'; echo '</tr>'; echo "</{$section}>"; } echo "<tbody>"; foreach ($all as $plugin) { $plugin_data = AgmPluginsHandler::get_plugin_info($plugin); if (!@$plugin_data['Name']) { continue; } // Require the name $is_active = in_array($plugin, $active); echo "<tr>"; echo "<td width='30%'>"; echo '<b>' . $plugin_data['Name'] . '</b>'; echo "<br />"; echo $is_active ? '<a href="#deactivate" class="agm_deactivate_plugin" agm:plugin_id="' . esc_attr($plugin) . '">' . __('Deactivate', 'agm_google_maps') . '</a>' : '<a href="#activate" class="agm_activate_plugin" agm:plugin_id="' . esc_attr($plugin) . '">' . __('Activate', 'agm_google_maps') . '</a>'; echo "</td>"; echo '<td>' . $plugin_data['Description'] . '<br />' . sprintf(__('Version %s', 'agm_google_maps'), $plugin_data['Version']) . ' | ' . sprintf(__('by %s', 'agm_google_maps'), '<a href="' . $plugin_data['Plugin URI'] . '">' . $plugin_data['Author'] . '</a>') . '</td>'; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo <<<EOAgmPluginJs <script type="text/javascript"> (function (\$) { \$(function () { \t\$(".agm_activate_plugin").click(function () { \t\tvar me = \$(this); \t\tvar plugin_id = me.attr("agm:plugin_id"); \t\t\$.post(ajaxurl, {"action": "agm_activate_plugin", "plugin": plugin_id}, function (data) { \t\t\twindow.location = window.location; \t\t}); \t\treturn false; \t}); \t\$(".agm_deactivate_plugin").click(function () { \t\tvar me = \$(this); \t\tvar plugin_id = me.attr("agm:plugin_id"); \t\t\$.post(ajaxurl, {"action": "agm_deactivate_plugin", "plugin": plugin_id}, function (data) { \t\t\twindow.location = window.location; \t\t}); \t\treturn false; \t}); }); })(jQuery); </script> EOAgmPluginJs; }
function json_deactivate_plugin() { $status = AgmPluginsHandler::deactivate_plugin($_POST['plugin']); echo json_encode(array('status' => $status ? 1 : 0)); exit; }
$textdomain_handler = 'load_plugin_textdomain'; } else { // No textdomain is loaded because we can't determine the plugin location. // No point in trying to add textdomain to string and/or localizing it. wp_die(__('There was an issue determining where Google Maps plugin is installed. Please reinstall.')); } } } $textdomain_handler('agm_google_maps', false, AGM_PLUGIN_SELF_DIRNAME . '/languages/'); // Post Indexer (http://premium.wpmudev.org/project/post-indexer) integration define('AGM_USE_POST_INDEXER', function_exists('post_indexer_make_current'), true); require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_map_model.php'; require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_maps_widget.php'; require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_plugin_installer.php'; register_activation_hook(__FILE__, array('AgmPluginInstaller', 'install')); AgmPluginInstaller::check(); add_action('widgets_init', create_function('', "register_widget('AgmMapsWidget');")); if (is_admin()) { require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_admin_help.php'; } require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_plugins_handler.php'; AgmPluginsHandler::init(); if (is_admin()) { require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_admin_form_renderer.php'; require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_admin_maps.php'; AgmAdminMaps::serve(); } else { require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_marker_replacer.php'; require_once AGM_PLUGIN_BASE_DIR . '/lib/class_agm_user_maps.php'; AgmUserMaps::serve(); }