include_once $mu_plugin; } unset($mu_plugin); // Load network activated plugins. if (is_multisite()) { foreach (wp_get_active_network_plugins() as $network_plugin) { include_once $network_plugin; } unset($network_plugin); } do_action('muplugins_loaded'); if (is_multisite()) { ms_cookie_constants(); } // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies(). wp_cookie_constants(); // Define and enforce our SSL constants wp_ssl_constants(); // Create common globals. require ABSPATH . WPINC . '/vars.php'; // Make taxonomies and posts available to plugins and themes. // @plugin authors: warning: these get registered again on the init hook. create_initial_taxonomies(); create_initial_post_types(); // Register the default theme directory root register_theme_directory(get_theme_root()); // Load active plugins. foreach (wp_get_active_and_valid_plugins() as $plugin) { include_once $plugin; } unset($plugin);
public function requireCookieConstants() { wp_cookie_constants(); }
function mmb_set_logged_in_cookie($logged_in_cookie) { if (!defined('MMB_USER_LOGIN')) { return false; } if (!defined('COOKIEHASH')) { wp_cookie_constants(); } $_COOKIE['wordpress_logged_in_' . COOKIEHASH] = $logged_in_cookie; }
/** * Check if Gravity Forms plugin is active and show notice if not. * * @since 1.12 * * @access public * @return boolean True: checks have been passed; GV is fine to run; False: checks have failed, don't continue loading */ public static function check_gravityforms() { // Bypass other checks: if the class exists if (class_exists('GFCommon')) { // and the version's right, we're good. if (true === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=")) { return true; } // Or the version's wrong self::$notices['gf_version'] = array('class' => 'error', 'message' => sprintf(__("%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at \$39%s%s", 'gravityview'), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . GFCommon::$version . '</span>', "\n\n" . '<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>')); return false; } $gf_status = self::get_plugin_status('gravityforms/gravityforms.php'); /** * The plugin is activated and yet somehow GFCommon didn't get picked up... * OR * It's the Network Admin and we just don't know whether the sites have GF activated themselves. */ if (true === $gf_status || is_network_admin()) { return true; } // If GFCommon doesn't exist, assume GF not active $return = false; switch ($gf_status) { case 'inactive': // Required for multisite if (!function_exists('wp_create_nonce')) { require_once ABSPATH . WPINC . '/pluggable.php'; } // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" if (is_multisite()) { wp_cookie_constants(); } $return = false; $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="' . wp_nonce_url(admin_url('plugins.php?action=activate&plugin=gravityforms/gravityforms.php'), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; self::$notices['gf_inactive'] = array('class' => 'error', 'message' => sprintf(__('%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview'), '<h3>', "</h3>\n\n" . $button, '</a></strong>')); break; default: self::$notices['gf_installed'] = array('class' => 'error', 'message' => sprintf(__('%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview'), '<h3>', "</h3>\n\n" . '<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>')); break; } return $return; }
public function initialise($options = array()) { if ($this->get('initialised') == true) { return; } // Set the language in the class. $config = MFactory::getConfig(); // Check that we were given a language in the array (since by default may be blank). if (isset($options['language'])) { $config->set('language', $options['language']); } #for-multi-db if (!defined('COOKIEHASH')) { wp_cookie_constants(); } // Set user specific editor. $user = MFactory::getUser(); $editor = $user->getParam('editor', $this->getCfg('editor')); if (!MPluginHelper::isEnabled('editors', $editor)) { $editor = $this->getCfg('editor'); if (!MPluginHelper::isEnabled('editors', $editor)) { $editor = 'none'; } } $config->set('editor', $editor); // Trigger the onAfterInitialise event. MPluginHelper::importPlugin('system'); $this->triggerEvent('onAfterInitialise'); $this->set('initialised', true); }
function jobman_get_application_csv() { if (is_multisite()) { // Multisite seems to do some late loading. We need the cookie info now, so we can validate the user. require_once ABSPATH . WPINC . '/default-constants.php'; wp_cookie_constants(); } require_once ABSPATH . WPINC . '/pluggable.php'; $options = get_option('jobman_options'); header('Cache-Control: no-cache'); header('Expires: -1'); if (!current_user_can('read_private_pages')) { header($_SERVER["SERVER_PROTOCOL"] . ' 403 Forbidden'); header('Refresh: 0; url=' . admin_url()); echo '<html><head><title>403 Forbidden</title></head><body><p>Access is forbidden.</p></body></html>'; exit; } header('Content-Type: application/force-download'); header('Content-type: text/csv'); header('Content-Type: application/download'); header("Content-Disposition: attachment; filename=applications.csv\t"); $fields = $options['fields']; $out = fopen('php://output', 'w'); if (count($fields) > 0) { uasort($fields, 'jobman_sort_fields'); $labels = array(); foreach ($fields as $field) { $labels[] = $field['label']; } fputcsv($out, $labels); $posts = array(); if (array_key_exists('application', $_REQUEST) && is_array($_REQUEST['application'])) { $posts = $_REQUEST['application']; } $apps = get_posts(array('post_type' => 'jobman_app', 'post__in' => $posts, 'numberposts' => -1, 'post_status' => 'public,private')); if (count($apps) > 0) { foreach ($apps as $app) { $data = array(); $appmeta = get_post_custom($app->ID); $appdata = array(); foreach ($appmeta as $key => $value) { if (is_array($value)) { $appdata[$key] = $value[0]; } else { $appdata[$key] = $value; } } foreach ($fields as $id => $field) { if (array_key_exists("data{$id}", $appdata)) { $item = $appdata["data{$id}"]; switch ($field['type']) { case 'text': case 'radio': case 'checkbox': case 'date': case 'textarea': case 'select': $data[] = $item; break; case 'file': $data[] = admin_url("admin.php?page=jobman-list-applications&appid={$app->ID}&getfile={$item}"); break; case 'geoloc': $data[] = $appdata['data-display' . $id] . ' (' . $item . ')'; break; default: $data[] = ''; } } else { $data[] = ''; } } fputcsv($out, $data); } } } fclose($out); exit; }
/** * Include only the WP files needed * * This brilliant piece of code (cough) is from the dsIDXpress plugin. * * @since 1.3 */ function bootstrap_wp_for_direct_access() { /** @define "$bootstrap_dir" "/srv/www/wordpress-default" */ $bootstrap_dir = dirname($_SERVER['SCRIPT_FILENAME']); /** @define "$bootstrap_dir" "/srv/www" */ $document_root = dirname(isset($_SERVER['APPL_PHYSICAL_PATH']) ? $_SERVER['APPL_PHYSICAL_PATH'] : $_SERVER['DOCUMENT_ROOT']); // Loop through folders and keep looking up the directories until you find a directory that has wp-load.php while (!file_exists($bootstrap_dir . '/wp-load.php')) { $bootstrap_dir = dirname($bootstrap_dir); // The base is no longer part of the path. We're in the weeds. // Let's fall back to default relative path to this file from wordpress // (wp-content/plugins/gravityview-datatables/includes/) if (false === strpos($bootstrap_dir, $document_root)) { $bootstrap_dir = "../../../../.."; break; } } require $bootstrap_dir . '/wp-load.php'; // Only load what we need. if (!function_exists('get_locale')) { require_once ABSPATH . WPINC . '/locale.php'; // is_rtl() require_once ABSPATH . WPINC . '/class-wp-walker.php'; // Needed for GF require_once ABSPATH . WPINC . '/plugin.php'; require_once ABSPATH . WPINC . '/load.php'; require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/general-template.php'; require_once ABSPATH . WPINC . '/link-template.php'; require_once ABSPATH . WPINC . '/formatting.php'; require_once ABSPATH . WPINC . '/kses.php'; require_once ABSPATH . WPINC . '/pluggable.php'; require_once ABSPATH . WPINC . '/capabilities.php'; require_once ABSPATH . WPINC . '/user.php'; require_once ABSPATH . WPINC . '/meta.php'; require_once ABSPATH . WPINC . '/session.php'; require_once ABSPATH . WPINC . '/shortcodes.php'; require_once ABSPATH . WPINC . '/theme.php'; require_once ABSPATH . WPINC . '/template.php'; require_once ABSPATH . WPINC . '/widgets.php'; require_once ABSPATH . WPINC . '/rewrite.php'; require_once ABSPATH . WPINC . '/query.php'; } // Setup WP_PLUGIN_URL, WP_PLUGIN_DIR, etc. if (function_exists('wp_plugin_directory_constants')) { wp_plugin_directory_constants(); } // USER_COOKIE, AUTH_COOKIE, etc. if (function_exists('wp_cookie_constants')) { wp_cookie_constants(); } // TEMPLATEPATH, STYLESHEETPATH, etc. if (function_exists('wp_templating_constants')) { wp_templating_constants(); } }
/** * Check if WooCommerce plugin is active and show notice if not. * * @since 2.0.13 * * @access public * @return boolean True: checks have been passed; WooCommerce MailChimp is fine to run; False: checks have failed, don't continue loading */ public static function check_woocommerce() { $woocommerce_is_active = false; // Bypass other checks: if the class exists if (class_exists('WooCommerce')) { $woocommerce_is_active = true; $woocommerce_version = WC()->version; } else { if ($wc_status = self::get_plugin_status('woocommerce/woocommerce.php')) { if (true === $wc_status) { $woocommerce_is_active = true; } $wc_data = get_plugin_data(WP_CONTENT_DIR . '/plugins/woocommerce/woocommerce.php'); $woocommerce_version = $wc_data['Version']; } } if (true === $woocommerce_is_active) { // and the version's right, we're good. if (true === version_compare($woocommerce_version, SS_WC_MAILCHIMP_MIN_WC_VERSION, ">=")) { return true; } $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="' . wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=woocommerce/woocommerce.php'), 'upgrade-plugin_woocommerce/woocommerce.php') . '" class="button button-large">'; // Or the version's wrong self::$notices['wc_version'] = array('class' => 'notice-error', 'message' => sprintf(__("%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp plugin.", 'woocommerce-mailchimp'), '<h3>', SS_WC_MAILCHIMP_MIN_WC_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">' . $woocommerce_version . '</span>', $button, '</strong></a>')); return false; } /** * The plugin is activated and yet somehow WooCommerce didn't get picked up... * OR * It's the Network Admin and we just don't know whether the sites have WooCommerce activated themselves. */ if ($woocommerce_is_active || is_network_admin()) { return true; } // If WooCommerce doesn't exist, assume WooCommerce not active $return = false; switch ($wc_status) { case 'inactive': // Required for multisite if (!function_exists('wp_create_nonce')) { require_once ABSPATH . WPINC . '/pluggable.php'; } // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" if (is_multisite()) { wp_cookie_constants(); } $return = false; $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="' . wp_nonce_url(admin_url('plugins.php?action=activate&plugin=woocommerce/woocommerce.php'), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">'; self::$notices['wc_inactive'] = array('class' => 'error', 'message' => sprintf(__('%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp'), '<h3>', "</h3>\n\n" . $button, '</a></strong>')); break; default: $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="' . wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=woocommerce'), 'install-plugin_woocommerce') . '" class="button button-large">'; self::$notices['wc_installed'] = array('class' => 'error', 'message' => sprintf(__('%sWooCommerce MailChimp requires WooCommerce to be installed in order to run properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp'), '<h3>', "</h3>\n\n" . $button, '</a></strong>')); break; } return $return; }