/** * Adds a reference of this object to $instance, populates default strings, * * @see CP_Plugin_Activation::init() */ public function __construct() { global $coursepress, $plugin_dir, $screen_base; // Bail out if we're on Campus if (CoursePress_Capabilities::is_campus()) { return false; } //Menu where plugin could be installed $this->tab = 'cp-marketpress'; $this->menu = $screen_base . '_settings&tab=' . $this->tab; $this->plugins['marketpress'] = array('name' => 'MarketPress', 'slug' => 'marketpress', 'base_path' => 'marketpress/marketpress.php', 'source' => is_object($coursepress) ? $coursepress->plugin_dir . 'includes/plugins/' . $coursepress->mp_file : '', 'source_message' => __('Included in the CoursePress Plugin', 'cp'), 'alt_message' => __('Plugin already installed.', 'cp'), 'external_url' => ''); $this->plugins['wordpress-ecommerce'] = array('name' => 'MarketPress - WordPress eCommerce', 'slug' => 'wordpress-ecommerce', 'alt_slug' => 'marketpress', 'base_path' => 'wordpress-ecommerce/marketpress.php', 'source' => 'downloads.wordpress.org/plugin/wordpress-ecommerce.zip', 'source_message' => __('WordPress.org Repository', 'cp'), 'external_url' => ''); if (CoursePress_Capabilities::is_pro()) { $this->plugin = $this->plugins['marketpress']; } if (!CoursePress_Capabilities::is_pro()) { $this->plugin = $this->plugins['wordpress-ecommerce']; } if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } // If its one or the other, override it here if (!empty($this->plugin['alt_slug']) && $this->is_plugin_installed('/' . $this->plugin['alt_slug'])) { $this->plugin = $this->plugins[$this->plugin['alt_slug']]; $this->plugin['source_message'] = !empty($this->plugin['alt_message']) ? $this->plugin['alt_message'] : ''; } $this->config = array('default_path' => '', 'menu' => $screen_base . '_settings&tab=' . $this->tab, 'has_notices' => true, 'dismissable' => true, 'dismiss_msg' => '', 'message' => ''); $this->strings = array('page_title' => __('Install Plugin', 'cp'), 'installing' => sprintf(__('Installing Plugin: %s', 'cp'), $this->plugin['name']), 'oops' => __('Something went wrong with the plugin API.', 'cp'), 'notice_can_install_recommended' => sprintf(__('Install %1$s plugin in order to sell courses.', 'cp'), $this->plugin['name']), 'notice_can_activate_recommended' => '', 'install_link' => sprintf(__('Install %1$s', 'cp'), $this->plugin['name']), 'activate_link' => sprintf(__('Activate %1$s plugin in order to sell courses', 'cp'), $this->plugin['name']), 'return' => __('Return to MarketPress Installer', 'cp'), 'dashboard' => __('Return to the dashboard', 'cp'), 'plugin_activated' => __('Plugin activated successfully.', 'cp'), 'activated_successfully' => __('The following plugin was activated successfully:', 'cp'), 'complete' => __('Installed and activated successfully.', 'cp'), 'dismiss' => __('Dismiss this notice', 'cp')); self::$instance = $this; // Set the current WordPress version. global $wp_version; $this->wp_version = $wp_version; // When the rest of WP has loaded, kick-start the rest of the class. add_action('init', array($this, 'init')); }
public static function is_active() { // Don't allow on campus if (CoursePress_Capabilities::is_campus()) { return false; } $plugins = get_option('active_plugins'); $activated = false; if (is_multisite()) { $active_sitewide_plugins = get_site_option("active_sitewide_plugins"); } else { $active_sitewide_plugins = array(); } foreach ($plugins as $plugin) { $activated = preg_match('/marketpress.php/', $plugin) || $activated; } foreach ($active_sitewide_plugins as $plugin => $signature) { $activated = preg_match('/marketpress.php/', $plugin) || $activated; } return $activated; }
function marketpress_check() { // Don't allow on campus if (CoursePress_Capabilities::is_campus()) { return false; } if (CoursePress::instance()->is_marketpress_lite_active() || CoursePress::instance()->is_cp_marketpress_lite_active() || CoursePress::instance()->is_marketpress_active()) { CoursePress::instance()->marketpress_active = true; } else { CoursePress::instance()->marketpress_active = false; } }
*/ /** * Add filters for shortcodes. * * @since 1.2.1 */ function add_shortcode_filters() { add_filter('shortcode_atts_course_cost', array(&$this, 'remove_shortcode_cost_labels'), 10, 3); add_filter('shortcode_atts_course_structure', array(&$this, 'remove_shortcode_cost_labels'), 10, 3); } /** * Remove FREE price label from shortcodes. * * @since 1.2.1 */ function remove_shortcode_cost_labels($out, $pairs, $atts) { if (isset($out['show_icon'])) { $out['show_icon'] = false; } if (isset($out['no_cost_text'])) { $out['no_cost_text'] = ''; } return $out; } } } if (CoursePress_Capabilities::is_campus()) { $coursepress_campus = new CoursePress_Campus(); }
/** * flush_rewrite_rules() wrapper for CoursePress. * * Used to wrap flush_rewrite_rules() so that rewrite flushes can * be prevented in given environments. * * E.g. If we've got CampusPress/Edublogs then this method will have * an early exit. * * @since 1.2.1 */ function cp_flush_rewrite_rules() { if (CoursePress_Capabilities::is_campus()) { return; } flush_rewrite_rules(); }