function em_ms_upgrade($blog_id) { ?> <div class="wrap"> <div id='icon-options-general' class='icon32'><br /></div> <h2><?php esc_html_e('Update Network', 'dbem'); ?> </h2> <?php if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'upgrade' && check_admin_referer('em_ms_ugrade_' . get_current_user_id())) { global $current_site, $wpdb; $blog_ids = $wpdb->get_col('SELECT blog_id FROM ' . $wpdb->blogs . ' WHERE site_id=' . $current_site->id); foreach ($blog_ids as $blog_id) { $plugin_basename = plugin_basename(dirname(dirname(__FILE__)) . '/events-manager.php'); if (in_array($plugin_basename, (array) get_blog_option($blog_id, 'active_plugins', array())) || is_plugin_active_for_network($plugin_basename)) { if (EM_VERSION > get_blog_option($blog_id, 'dbem_version', 0)) { switch_to_blog($blog_id); require_once dirname(__FILE__) . '/../em-install.php'; em_install(); echo "<p>Upgraded - " . get_bloginfo('blogname') . "</p>"; restore_current_blog(); } else { echo "<p>"" . get_blog_option($blog_id, 'blogname') . "" is up to date.</p>"; } } else { echo "<p>"" . get_blog_option($blog_id, 'blogname') . "" does not have Events Manager activated.</p>"; } } echo "<p>Done Upgrading</p>"; } else { ?> <form action="" method="post"> <p><?php esc_html_e('To update your network blogs with the latest Events Manager automatically, click the update button below.', 'dbem'); ?> </p> <input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('em_ms_ugrade_' . get_current_user_id()); ?> " /> <input type="hidden" name="action" value="upgrade" /> <input type="submit" value="<?php esc_attr_e('Update', 'dbem'); ?> " /> </form> <?php } ?> </div> <?php }
function em_network_install($networkwide) { global $wpdb; if (function_exists('is_multisite') && is_multisite()) { // check if it is a network activation - if so, run the activation function for each blog id if ($networkwide) { $old_blog = $wpdb->blogid; // Get all blog ids $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); foreach ($blogids as $blog_id) { switch_to_blog($blog_id); em_install(); } switch_to_blog($old_blog); return; } } em_install(); }
function em_reimport() { //Check for reimport request global $wpdb; if ($_GET['em_reimport'] == 1) { check_admin_referer('em_reimport'); $p = $wpdb->prefix; $table_bookings = $p . EM_BOOKINGS_TABLE; $table_categories = $p . EM_CATEGORIES_TABLE; $table_events = $p . EM_EVENTS_TABLE; $table_locations = $p . EM_LOCATIONS_TABLE; $table_people = $p . EM_PEOPLE_TABLE; $wpdb->query('DROP TABLE ' . $table_bookings . ', ' . $table_categories . ', ' . $table_events . ', ' . $table_locations . ', ' . $table_people . ';'); update_option('dbem_version', '2'); em_install(); } }
function em_activate() { require_once WP_PLUGIN_DIR . '/events-manager/em-install.php'; em_install(); }
/** * Perform init actions */ function em_init() { //Hard Links global $EM_Mailer, $wp_rewrite; if (get_option("dbem_events_page") > 0) { define('EM_URI', get_permalink(get_option("dbem_events_page"))); //PAGE URI OF EM } else { if ($wp_rewrite->using_permalinks()) { define('EM_URI', trailingslashit(home_url()) . '/' . EM_POST_TYPE_EVENT_SLUG . '/'); //PAGE URI OF EM } else { define('EM_URI', trailingslashit(home_url()) . '?post_type=' . EM_POST_TYPE_EVENT); //PAGE URI OF EM } } if ($wp_rewrite->using_permalinks()) { define('EM_RSS_URI', trailingslashit(EM_URI) . "rss/"); //RSS PAGE URI } else { if (get_option("dbem_events_page") > 0) { define('EM_RSS_URI', EM_URI . "&rss=1"); //RSS PAGE URI } else { define('EM_RSS_URI', EM_URI . "&feed=rss2"); //RSS PAGE URI } } $EM_Mailer = new EM_Mailer(); //Upgrade/Install Routine if (is_admin() && current_user_can('activate_plugins')) { if (EM_VERSION > get_option('dbem_version', 0)) { require_once dirname(__FILE__) . '/em-install.php'; em_install(); } } //add custom functions.php file locate_template('plugins/events-manager/functions.php', true); }
/** * Perform init actions */ function em_init() { //Hard Links global $EM_Mailer, $wp_rewrite; if (get_option("dbem_events_page") > 0) { define('EM_URI', get_permalink(get_option("dbem_events_page"))); //PAGE URI OF EM } else { if ($wp_rewrite->using_permalinks()) { define('EM_URI', trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/'); //PAGE URI OF EM } else { define('EM_URI', trailingslashit(home_url()) . '?post_type=' . EM_POST_TYPE_EVENT); //PAGE URI OF EM } } if ($wp_rewrite->using_permalinks()) { define('EM_RSS_URI', trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/feed/'); //RSS PAGE URI via CPT archives page } else { define('EM_RSS_URI', em_add_get_params(home_url(), array('post_type' => EM_POST_TYPE_EVENT, 'feed' => 'rss2'))); //RSS PAGE URI } $EM_Mailer = new EM_Mailer(); //Upgrade/Install Routine if (is_admin() && current_user_can('list_users')) { if (EM_VERSION > get_option('dbem_version', 0) || is_multisite() && !EM_MS_GLOBAL && get_option('em_ms_global_install')) { require_once dirname(__FILE__) . '/em-install.php'; em_install(); } } //add custom functions.php file locate_template('plugins/events-manager/functions.php', true); }
function em_activate() { global $wp_rewrite; $wp_rewrite->flush_rules(); require_once dirname(__FILE__) . '/em-install.php'; em_install(); }
/** * Perform init actions */ function em_init() { //Hard Links global $EM_Mailer, $wpdb, $wp_rewrite; define('EM_URI', get_permalink(get_option("dbem_events_page"))); //PAGE URI OF EM if ($wp_rewrite->using_permalinks()) { define('EM_RSS_URI', trailingslashit(EM_URI) . "rss/"); //RSS PAGE URI } else { define('EM_RSS_URI', EM_URI . "&rss=1"); //RSS PAGE URI } $EM_Mailer = new EM_Mailer(); //Upgrade/Install Routine if (is_admin() && current_user_can('activate_plugins')) { if (EM_VERSION > get_option('dbem_version', 0)) { require_once dirname(__FILE__) . '/em-install.php'; em_install(); } } }